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.
Extending this class<?php /** * New class description goes here * * @author Your Name, 2024-11-24 **/ class NewClassName extends Validity { /** * Checks that a value is a valid IPv4 CIDR block **/ public function ipv4Cidr (string $val) { // Method code goes here } /** * Checks that a value is a valid IPv4 address **/ public function ipv4Addr (string $val) { // Method code goes here } /** * Checks that a value is a valid IPv4 address or CIDR block **/ public function ipv4AddrOrCidr (string $val) { // Method code goes here } /** * Checks a value matches an ID in a corresponding table **/ public function inTable (string $val, string $table) { // Method code goes here } /** * Checks all selected values match IDs in a corresponding table **/ public function allInTable (array $val, string $table) { // Method code goes here } /** * Checks that a value is numeric (integral or decimal) **/ public function numeric (string $val) { // Method code goes here } /** * Checks that a value is binary; either a '1' or a '0'. **/ public function binary (string $val) { // Method code goes here } /** * Checks that a value is numeric (integral or decimal) and within a given inclusive range **/ public function range (string $val, number $min, number $max) { // Method code goes here } /** * Validates a value meant for an ENUM field **/ public function inEnum (string $val, string $table, string $col) { // Method code goes here } /** * Checks that a date range is valid. **/ public function dateRange (array $vals, string $min, string $max, bool $enforce_ordering) { // Method code goes here } /** * Checks that a value matches a regular expression **/ public function regex (string $val, string $pattern) { // Method code goes here } /** * Checks each value of an array is one of the allowed values **/ public function allInArray (array $val, array $allowed) { // Method code goes here } /** * Checks a value is one of the allowed values **/ public function inArray (string $val, array $allowed) { // Method code goes here } /** * At least one value must be specified (e.g. one of email/phone/mobile) **/ public function oneRequired (array $vals) { // Method code goes here } /** * All field values must match (e.g. password1 and password2 must match) **/ public function allMatch (array $vals) { // Method code goes here } /** * All field values must be unique (e.g. home phone and work phone cannot be the same) **/ public function allUnique (array $vals) { // Method code goes here } /** * Checks all selected values belong to a database SET definition **/ public function allInSet (array $val, string $table, string $col) { // Method code goes here } /** * 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. **/ public function uniqueValue (string $val, string $table, string $column, int $id, string $error_msg) { // Method code goes here } /** * Checks if a value is a time in MySQL format (HH:MM:SS) **/ public function timeMySQL (string $val) { // Method code goes here } /** * Checks if a value is a datetime in MySQL format (YYYY-MM-DD HH:MM:SS) **/ public function datetimeMySQL (string $val) { // Method code goes here } /** * Validate email, commonly used characters only **/ public function email (string $val) { // Method code goes here } /** * Validate password by length, type of characters, and list of common passwords **/ public function password (string $val) { // Method code goes here } /** * Checks if a phone number is valid. **/ public function phone (string $val, int $min_digits) { // Method code goes here } /** * Checks if a value is a positive integer **/ public function positiveInt (string $val) { // Method code goes here } /** * Checks whether a string is made up of the kinds of characters that make up prose * * Allowed: letters, numbers, space, punctuation * Allowed punctuation: * ' " / ! ? @ # $ % & ( ) - : ; . , **/ public function proseText (string $str) { // Method code goes here } /** * Checks if a value is a date in MySQL format (YYYY-MM-DD) **/ public function dateMySQL (string $val) { // Method code goes here } /** * Checks the length of a string is within an allowed range **/ public function length (string $val, int $min, int $max) { // Method code goes here } } ?> |
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 |