Module rules

Source
Expand description

§Built-in Validation Rules

Provides common validation rules ready to use:

§Basic Type Validation

  • required() - Value must not be null
  • string() - Value must be a string
  • integer() - Value must be an integer
  • float() - Value must be a float
  • boolean() - Value must be a boolean
  • array() - Value must be an array
  • object() - Value must be an object

§String Validation

  • length(n) - Exact length
  • min_length(n) - Minimum length
  • max_length(n) - Maximum length
  • email() - Valid email format
  • url() - Valid URL format
  • ip() - Valid IP address
  • regex() - Matches regex pattern

§Numeric Validation

  • min_value(n) - Minimum numeric value
  • max_value(n) - Maximum numeric value
  • equal(n) - Exact value match

§Collection Validation

  • in_values() - Value must be in allowed set
  • not_in_values() - Value must not be in excluded set

§Database Validation

  • unique() - Field value must be unique in MongoDB collection

§Custom Validation

  • custom() - Implement custom validation logic

Structs§

Rule
Factory for creating validation rules