These directives validate field values in route parameters, request bodies, or model definitions.
Validates string values with various constraints.
Parameters:
min_len: Minimum length of the stringmax_len: Maximum length of the stringexact_len: Exact length the string must havestart_with: String must start with this prefixend_with: String must end with this suffixValidates numeric values against specified constraints.
Parameters:
min: Minimum valuemax: Maximum valueequal: Value must equal this numberValidates that a value is one of a set of allowed values.
Validates that a string matches a given regular expression pattern.
Validates that a string conforms to a specific format.
Supported formats:
email: Email addressurl: URLuuid: UUIDipv4: IPv4 addressipv6: IPv6 addressdate: Date (YYYY-MM-DD)datetime: Datetime (ISO 8601)time: Time (HH:MM:SS)month: Month (YYYY-MM)week: Week (YYYY-Www)color: HTML color codeuscc: Unified Social Credit CodeValidates arrays against specified constraints.
Parameters:
min_len: Minimum number of itemsmax_len: Maximum number of itemsunique: Whether items must be uniqueValidates that a string is a valid date in the specified format and range.
Parameters:
format: Date format string (default: "YYYY-MM-DD")min: Minimum datemax: Maximum dateNegates another validator, passing if the inner validator fails.
Combines multiple validators with logical OR, passing if any of the inner validators pass.