| Rule | Parameter | Description | Example |
| not_empty | No | Returns FALSE if form field is empty | |
| min_length | Yes | Returns FALSE if the field is too short | length[5] - minimum 5 characters long |
| max_length | Yes | Returns FALSE if the field is too long | length[30] - maximum 30 characters long |
| exact_length | Yes | Returns FALSE if the field is too short or too long | length[25] - 25 characters only |
| matches | Yes | Returns FALSE if field does not match field(s) in parameter | matches[password_again] |
| date | No | Returns FALSE if form field is not a valid date | |
| regex | Yes | Returns FALSE if form field does not fulfill the regular expression | regex[expression] - regular expression to match (including delimiters) |
| Optional | Returns FALSE if email is not valid | mail[TRUE] - rfc822 strict | |
| email_domain | No | Returns FALSE if domain of an email does not have valid MX record | |
| url | No | Returns FALSE if url is not valid | |
| ip | Optional | Returns FALSE if ip is not valid | ip[TRUE] - allow private IP networks |
| credit_card | Yes | Returns FALSE if credit card is not valid | credit_card[mastercard] - card type, or an array of card types |
| phone | Optional | Returns FALSE if phone number is not a valid length | phone[7,10,11,14] - either 7, 10, 11 or 14 digits long (default is 7, 10 and 11) |
| alpha | Optional | Returns FALSE if form field does not consist only of alphabetical characters only | alpha[TRUE] - trigger UTF-8 compatibility |
| alpha_numeric | Optional | Returns FALSE if form field does not consist only of alphabetical or numeric characters | alpha_numeric[TRUE] - trigger UTF-8 compatibility |
| alpha_dash | Optional | Returns FALSE if form field does not consist only of alphabetical, numeric, underscore and dash characters | alpha_dash[TRUE] - trigger UTF-8 compatibility |
| digit | Optional | Returns FALSE if form field does not consist only of digit characters (no dots or dashes). | digit[TRUE] - trigger UTF-8 compatibility |
| numeric | No | Returns FALSE if form field is not a valid number (positive, negative or decimal) | |
| decimal | Optional | Returns FALSE if form field is not in proper decimal format | decimal - is any valid decimal format |
| Optional parameter is for a specific decimal format | decimal[4,2] - is 4 digits and 2 decimal places | ||
| range | Yes | Returns FALSE if form field is not withing the range min and max | range[1,10] - between 1 and 10 include |
| color | No | Returns FALSE if form field is not proper hexadecimal HTML color value |
Tuesday, September 24, 2013
Kohana 3 Validation Rules / Kohana 3 Validation Option
Subscribe to:
Posts (Atom)