Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
34% | Total: 486 | All time: 5,907 This week: 455 |
Version | License | PHP version | Categories | |||
cs-form-validator 2.0 | MIT/X Consortium ... | 5.3 | PHP 5, Validation |
Description | Author | |
This class can validate submitted form values in multiple ways. |
its an easy and handy PHP form validator
first you have to set validation rules with input name
$rules=[
'name'=>'required&max:10',
'email'=>'required&email&unique:table,email_field'
];
> Noted: every rules will be separated by '&'
after setting up the rules then you have to validate the inputs
$valid=Validator::validate($input, $rules);
It will validate all of your inputs from your rules.
If you want to check that all of your input are valid then you have to use Validator::hasErrors()
if($valid->hasErrors()){
//do something
}
If error occurred then return true
If you want to get all errors then use the method Validator::errorsAll()
this method return all error messages as an array. so you can print all error by this procedure
foreach($valid->errorsAll() as $error){
echo '<li>'.$error.'</li>';
}
If you want to get specific field all message then use it. Validator::getErrors('name')
foreach($valid->getErrors('email') as $error){
echo '<li>'.$error.'</li>';
}
> Noted: Here all errors messages are stored in the session so you can > display it anywhere of the project
> here after the color ':' are mentioned for parameters of rules
- required - min:number [example: min:10] - max:number [example: max:10] - file - date - date_max:date [example: date_max:10-07-2014] - date_min:date [example: date_min:10-07-2014] - in:comma_separeted_string [example: in:3,4,asia,mango] - not_in:comma_separeted_string [example: not_in:3,4,asia,mango] - image - file_type:comma_separeted_string [example: file_type:jpg,png,bmp] - same:another_input_field [example: same:repassword] - different:another_input_field [example: different:firstName] - email [example: email] - url - numeric - integer - range:from,to [example: range:6,30] - pattern:regular_expression [example: pattern:/[0-9]/] - unique:table,column [example: unique:tbl_users,username] - exist:table,column [example: exist:tbl_users,username]
Files (4) |
File | Role | Description |
---|---|---|
index.php | Test | Unit test script |
LICENSE | Data | Auxiliary data |
README.md | Doc. | Documentation |
validator.php | Class | Validx Form Validator |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.