Validate

The Validate class in PHPFast is responsible for validating user input using the Respect\Validation library. It provides a collection of methods to check various types of data, such as strings, numbers, dates, emails, and even JSON or IP addresses.

This class helps ensure that data meets specific criteria before being processed or stored in a database, reducing errors and improving security.

Methods in Validate.php

String & Character Validations

// Ensures the string contains only letters (A-Z, a-z).
public static function alpha() {
    return RespectValidator::alpha();
}

// Ensures the string contains only numeric digits (0-9).
public static function digit() {
    return RespectValidator::digit();
}

// Ensures the string contains only lowercase letters.
public static function lowercase() {
    return RespectValidator::lowercase();
}

// Ensures the string contains only uppercase letters.
public static function uppercase() {
    return RespectValidator::uppercase();
}

Example:

Number & Range Validations

Example:

Email, URL, and IP Validations

Example:

Password & Security Validations

Example:

JSON, UUID, and Special Format Validations

Example:

Validating an Array of Data (check())

  • Validates multiple fields based on predefined rules.

  • Stores errors for fields that fail validation.

Example:

Last updated

Was this helpful?