class Validators (View source)

Utility class providing static validation methods for various data formats.

This helper centralizes all validation logic used throughout the system, ensuring consistency and reusability for user input, identifiers, and business rules.

Methods

static bool
validateCpf(string $cpf)

Validates a Brazilian CPF number.

static bool
validateCourseName(string $course)

Validates the structure of a course name.

static bool
validatePasswordStructure(string $password)

Validates a password structure according to system security rules.

static bool
validateFullName(string $name)

Validates a full name according to format and length rules.

static bool
validatePhoneNumber(string $number)

Validates a Brazilian mobile phone number.

static bool
validateEmail(string $email)

Validates the structure of an email address and checks MX DNS records.

static bool
validateIsbn(string $isbn)

Validates an ISBN-10 or ISBN-13 format and checksum.

static bool
validateLoanCode(string $code)

Validates a loan code in the format LNXXXXXXXX.

Details

static bool validateCpf(string $cpf)

Validates a Brazilian CPF number.

Parameters

string $cpf

the CPF number as a string (formatted or not)

Return Value

bool

true if the CPF is valid; otherwise, false

static bool validateCourseName(string $course)

Validates the structure of a course name.

Parameters

string $course

the course name to validate

Return Value

bool

true if the name meets the format requirements

static bool validatePasswordStructure(string $password)

Validates a password structure according to system security rules.

Password must:

  • Be 8–16 characters long.
  • Include at least one uppercase and one lowercase letter.
  • Include at least one digit and one special character.

Parameters

string $password

the password string to validate

Return Value

bool

true if the password meets the security requirements

See also

https://owasp.org/www-community/password-special-characters

static bool validateFullName(string $name)

Validates a full name according to format and length rules.

Name must contain:

  • Only letters, spaces, hyphens or apostrophes.
  • At least two words.
  • Between 3 and 100 characters.

Parameters

string $name

the full name to validate

Return Value

bool

true if valid, false otherwise

static bool validatePhoneNumber(string $number)

Validates a Brazilian mobile phone number.

Rules:

  • 11 digits (including DDD)
  • Valid DDD
  • Must start with 9 after the DDD

Parameters

string $number

the phone number to validate

Return Value

bool

true if valid; otherwise, false

static bool validateEmail(string $email)

Validates the structure of an email address and checks MX DNS records.

Parameters

string $email

the email address to validate

Return Value

bool

true if valid and domain has MX records; otherwise, false

static bool validateIsbn(string $isbn)

Validates an ISBN-10 or ISBN-13 format and checksum.

Parameters

string $isbn

the ISBN to validate

Return Value

bool

true if valid; otherwise, false

See also

https://en.wikipedia.org/wiki/International_Standard_Book_Number

static bool validateLoanCode(string $code)

Validates a loan code in the format LNXXXXXXXX.

Accepts both the full code (LN + 8 alphanumeric characters) or partial prefixes (for autocomplete use cases).

Parameters

string $code

the loan code to validate

Return Value

bool

true if valid; otherwise, false