Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mostafazs/php-validator
Validate form inputs
https://github.com/mostafazs/php-validator
Last synced: about 2 months ago
JSON representation
Validate form inputs
- Host: GitHub
- URL: https://github.com/mostafazs/php-validator
- Owner: mostafazs
- License: mit
- Created: 2017-04-22T03:31:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-19T18:14:19.000Z (over 2 years ago)
- Last Synced: 2024-04-24T16:19:30.348Z (9 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Validator
PHP form input validator.support validating common form input types,validate input from `$_POST` or any array.
## Installation
Require the package in `composer.json`
```json
"require": {
"mostafazs/php-validator": "1.*"
},
```If you are using Laravel, add an alias in `config/app.php`
```php
'aliases' => array('App' => 'Illuminate\Support\Facades\App',
...
'View' => 'Illuminate\Support\Facades\View','Validator' => 'mostafazs\php-validator',
),
```## Usage
### Check empty input
````php
$result = Validator::filledIn($input);
var_dump($result);
````### Check length of input
```php
$result = Validator::length($input,$operator,$length);
var_dump($result);
````
takes `<`,`>`,`=`,`>=`,`<=` as `$operator` argument### Validate email address
```php
$result = Validator::email($email);
var_dump($result);
````### Check equality of two input.
```php
$result = Validator::compase($einput1,$input2,caseSensitive);
var_dump($result);
````
sensitivity can be specified by adding `caseSensitive` to `true`### Check length of input to see is between tow value
```php
$result = Validator::lengthBetween($input,$min,$max,$inclusive);
var_dump($result);
````
inclusive can be specified by adding `$inclusive` to `true`### Check an integer input against arguments.
```php
$result = Validator::value($input,$operator,$length);
var_dump($result);
````
`$operator` Takes <, >, =, <=, and >= and === as operators### Validate just alphabetic character input
```php
$result = Validator::alpha($input);
var_dump($result);
````### Validate alphanumeric character input
```php
$result = Validator::alphanumeric($input);
var_dump($result);
````### Validate date by specified format
```php
$result = Validator::date($date,$format);
var_dump($result);
````
separators are "/" "." "-"
date formats "m" for month, "d" for day, "y" for year### Validate url
```php
$result = Validator::Url($input);
var_dump($result);
````### Validate IP address
```php
$result = Validator::Ip($input,$ip_version);
var_dump($result);
````
support IPv4 and IPv6