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
- Host: GitHub
- URL: https://github.com/hannasdev/validator
- Owner: hannasdev
- License: gpl-3.0
- Created: 2016-01-18T10:20:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-07T14:32:15.000Z (over 10 years ago)
- Last Synced: 2024-03-27T20:21:52.106Z (over 2 years ago)
- Language: PHP
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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