An open API service indexing awesome lists of open source software.

https://github.com/hannasdev/validator

A PHP validator class
https://github.com/hannasdev/validator

Last synced: 12 months ago
JSON representation

A PHP validator class

Awesome Lists containing this project

README

          

# Validator
A (static) PHP validator class. Lets you validate data according to different sets of rules, listed below.

## Rules

### minLength
*minLength($string, $max)*
Checks if a string has a minimum of x characters.
```php

```

### maxLength
*maxLength($string, $max)*

Checks if a string has a maximum of x characters.
```php

```

### matches
*matches($string, $matches)*

Checks if a string matches another.
```php

```

### hasNoSpecialChars
*hasNoSpecialChars($string)*

Checks that a string has no special characters: [\'^£$%&*}{@#~><>|=_+¬]
```php
window.alert("Hello");";
if (Validator::hasNoSpecialChars($string)) {
echo "Contains invalid characters!";
}
?>
```

### timeStamp
*timeStamp($string)*

Checks that a string is a valid timestamp.
```php

```

### yearMonth
*yearMonth($string)*

Checks that a string is made of year and month.
```php

```

### alphabetic
*alphabetic($string)*

Checks that a string is alphabetic.
```php

```

### alphaNumeric
*alphaNumeric($string)*

Checks that a string is alphanumeric.
```php

```

### digit
*digit($string)*

Checks that a string has only digits.
```php

```

### email
*email($string)*

Checks that a string is an email.
```php

```

### url
*URL($string)*

Checks that a string is an URL.
```php

```

### name
*name($string)*

Checks that a string is a name (only space and letters)
```php

```

## Escaping

### html
*html($string)*

Escapes a string so that it can safely be used in HTML.
```php

Name:


```

## Author
* Hanna Söderström
* info@hannasoderstrom.com