New validation class for Sprout 3. All of its methods should give useful errors by throwing a ValidationException. Used with the Validator class.
This is the code documentation for the SproutCMS project
Search documentation |
class ValidityNew validation class for Sprout 3. All of its methods should give useful errors by throwing a ValidationException. Used with the Validator class.
Functions
public allInArrayvoid Validity::allInArray ( array $val , array $allowed ); Checks each value of an array is one of the allowed values public allInSetvoid Validity::allInSet ( array $val , string $table , string $col ); Checks all selected values belong to a database SET definition public allInTablevoid Validity::allInTable ( array $val , string $table ); Checks all selected values match IDs in a corresponding table public allMatchvoid Validity::allMatch ( array $vals ); All field values must match (e.g. password1 and password2 must match) public allUniquevoid Validity::allUnique ( array $vals ); All field values must be unique (e.g. home phone and work phone cannot be the same) public binaryvoid Validity::binary ( string $val ); Checks that a value is binary; either a '1' or a '0'. public dateMySQLvoid Validity::dateMySQL ( string $val ); Checks if a value is a date in MySQL format (YYYY-MM-DD) public dateRangevoid Validity::dateRange ( array $vals [, string $min [, string $max [, bool $enforce_ordering ]]] ); Checks that a date range is valid. public datetimeMySQLvoid Validity::datetimeMySQL ( string $val ); Checks if a value is a datetime in MySQL format (YYYY-MM-DD HH:MM:SS) public emailvoid Validity::email ( string $val ); Validate email, commonly used characters only public inArrayvoid Validity::inArray ( string $val , array $allowed ); Checks a value is one of the allowed values public inEnumbool Validity::inEnum ( string $val , string $table , string $col ); Validates a value meant for an ENUM field public inTablevoid Validity::inTable ( string $val , string $table ); Checks a value matches an ID in a corresponding table public ipv4Addrvoid Validity::ipv4Addr ( string $val ); Checks that a value is a valid IPv4 address public ipv4AddrOrCidrvoid Validity::ipv4AddrOrCidr ( string $val ); Checks that a value is a valid IPv4 address or CIDR block public ipv4Cidrvoid Validity::ipv4Cidr ( string $val ); Checks that a value is a valid IPv4 CIDR block public lengthvoid Validity::length ( string $val , int $min , int $max ); Checks the length of a string is within an allowed range public numericvoid Validity::numeric ( string $val ); Checks that a value is numeric (integral or decimal) public oneRequiredvoid Validity::oneRequired ( array $vals ); At least one value must be specified (e.g. one of email/phone/mobile) public passwordvoid Validity::password ( string $val ); Validate password by length, type of characters, and list of common passwords public phonevoid Validity::phone ( string $val [, int $min_digits ] ); Checks if a phone number is valid. public positiveIntvoid Validity::positiveInt ( string $val ); Checks if a value is a positive integer public proseTextvoid Validity::proseText ( string $str ); Checks whether a string is made up of the kinds of characters that make up prose Allowed: letters, numbers, space, punctuation Allowed punctuation: ' " / ! ? @ # $ % & ( ) - : ; . , public rangevoid Validity::range ( string $val , number $min , number $max ); Checks that a value is numeric (integral or decimal) and within a given inclusive range public regexvoid Validity::regex ( string $val , string $pattern ); Checks that a value matches a regular expression public timeMySQLvoid Validity::timeMySQL ( string $val ); Checks if a value is a time in MySQL format (HH:MM:SS) public uniqueValuevoid Validity::uniqueValue ( string $val , string $table , string $column [, int $id [, string $error_msg ]] ); Checks that a unique value doesn't already exist in the database, e.g. a username or email address. This is to give a friendlier frontend to DB errors pertaining to UNIQUE constraints. N.B. this function uses LIKE for case-insensitive matching, so it's even stricter than a UNIQUE constraint. |
Powered by Pelzini, version 0.9.0 |
Documentation is made available under the
GNU Free Documentation License 1.2. Generated: Monday, 3rd April, 2023 at 02:59 pm |