Created
November 3, 2008 01:39
-
-
Save lantins/21777 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// set our attributes and values | |
$input_array = array( | |
'name' => 'luke', | |
'age' => 23, | |
'occupation' => 'developer' | |
); | |
$input_object = (object) $input_array; | |
$input = new itsy_validate($input_object); | |
$input->name->required() | |
->length(3, 16) | |
->text(); | |
$input->age->required() | |
->length(1, 3) | |
->digit(); | |
$input->occupation->length(0, 32) | |
->regex('^[a-z0-9_\ \.-]{3,16}$'); | |
$input->is_valid(); // returns true/false | |
$input->errors_on_all(); // returns an object of attributes and their error messages. | |
$input->errors_on('name'); // returns an object of error messages for the spesific attribute. | |
$input->name->errors(); // returns an object of error messages for the spesific attribute. | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment