Skip to content

Instantly share code, notes, and snippets.

@lantins
Created November 3, 2008 01:39
Show Gist options
  • Save lantins/21777 to your computer and use it in GitHub Desktop.
Save lantins/21777 to your computer and use it in GitHub Desktop.
<?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