validation library

Validation rules, the validator, form requests and messages.

A subset of package:daravel/daravel.dart for files that need only this area, or whose own names collide with the full barrel (JwtException, UniqueRule, ModelNotFoundException, CorsMiddleware, ...).

Classes

AcceptanceRule
accepted, declined and, with other, accepted_if and declined_if (laravel/framework ValidatesAttributes, the same from 8 to 13): the value must pass _test, only while other is one of values for the conditional rules. Implicit, so a missing attribute fails.
AlphaDashRule
alpha_dash: see Rules.alphaDash.
AlphaNumRule
alpha_num: see Rules.alphaNum.
AlphaRule
alpha: see Rules.alpha.
AsciiRule
ascii: see Rules.ascii.
BailRule
Marker: stop validating the attribute after the first failure.
BetweenRule
between: see Rules.between.
BooleanRule
boolean: see Rules.boolean.
ClosureRule
A rule from a closure: see Rules.custom.
CompareRule
gt, gte, lt and lte: against another field of the same type, or a number when the value is numeric too.
ConfirmedRule
confirmed: see Rules.confirmed.
DateCompareRule
after, after_or_equal, before, before_or_equal and date_equals.
DateFormatRule
date_format:Y-m-d[,d/m/Y]: the value, a string or a number, reads back exactly in one of formats (Laravel's validateDateFormat).
DateRule
date: see Rules.date.
DecimalRule
decimal:2 and decimal:0,4.
DependentRule
prohibited_if, prohibited_unless and present_if.
DigitCountRule
min_digits and max_digits: the length of a number made of digits.
DigitsBetweenRule
digits_between: see Rules.digitsBetween.
DigitsRule
digits: see Rules.digits.
DistinctRule
distinct: see Rules.distinct.
EmailRule
email: see Rules.email.
EndsWithRule
ends_with: see Rules.endsWith.
EnumRule<E extends Enum>
Rule::enum(): the value of one of values, by name or by toValue.
ExcludeRule
The rules that drop an attribute: passes answers its name when the attribute leaves the validated data, and no error is added.
ExistsRule
exists:table,column — the value must be present in the table.
ExtensionsRule
extensions:csv,txt: the extension of the client's file name.
FileRule
file: see Rules.file.
FilledRule
filled: see Rules.filled.
FormRequest
Reusable authorization + validation for a request (Laravel FormRequest).
ImageRule
image (jpg, jpeg, png, gif, bmp, webp; image:allow_svg adds svg).
InRule
in and not_in: see Rules.inList.
IntegerRule
integer: see Rules.integer.
IpRule
ip, ipv4 and ipv6: see Rules.ip.
JsonRule
json: see Rules.json.
ListRule
array for a JSON array: see Rules.list.
LowercaseRule
lowercase: see Rules.lowercase.
MapRule
array for a JSON object: see Rules.map.
MaxRule
max: see Rules.max.
MimesRule
mimes:jpg,png: the extension guessed from the content.
MimetypesRule
mimetypes:image/jpeg,video/*: the type detected from the content.
MinRule
min: see Rules.min.
MultipleOfRule
multiple_of: see Rules.multipleOf.
NullableRule
Marker: null values skip the remaining rules.
NumericRule
numeric: see Rules.numeric.
PasswordRule
Password: see Rules.password.
PresentRule
present: see Rules.present.
ProhibitedRule
prohibited: see Rules.prohibited.
ProhibitsRule
prohibits: the others must be empty while this one is not.
RegexRule
regex and not_regex: see Rules.regex.
RequiredIfAcceptedRule
required_if_accepted: see Rules.requiredIfAccepted.
RequiredIfRule
required_if: see Rules.requiredIf.
RequiredRule
required: see Rules.required.
RequiredUnlessRule
required_unless: see Rules.requiredUnless.
RequiredWithAllRule
required_with_all: see Rules.requiredWithAll.
RequiredWithoutAllRule
required_without_all: see Rules.requiredWithoutAll.
RequiredWithoutRule
required_without: see Rules.requiredWithout.
RequiredWithRule
required_with: see Rules.requiredWith.
Rule
A validation rule. passes returns null on success or a message reference on failure: either a translation key such as min.string (resolved with parameters) or a literal message containing a space.
RuleBuilder
Rules written as a chain, typed and checked by the compiler:
RuleParser
Parses Laravel's string rule DSL ('required|email|max:255') into Rule objects (ADR-020). Parsing happens once at definition time and unknown rules throw immediately, so typos surface at boot or in tests, never in a request.
Rules
Factory facade for built-in rules (Rule.required(), Rule.email()...). Each factory returns a const-friendly Rule subclass that can be introspected for messages and OpenAPI hints.
SameRule
same and different: see Rules.same.
SizeRule
size: see Rules.size.
SometimesRule
Marker: validate only when the attribute is present.
StartsWithRule
starts_with: see Rules.startsWith.
StringRule
string: see Rules.string.
TimezoneRule
PHP's timezone_identifiers_list by the group of the name. The database here also knows old aliases such as Asia/Calcutta, which PHP's list leaves out.
UlidRule
ulid: see Rules.ulid.
UniqueRule
unique:table,column,ignore,idColumn — queries the active connection (joining any Zone transaction).
UppercaseRule
uppercase: see Rules.uppercase.
UrlRule
url: see Rules.url.
UuidRule
uuid: see Rules.uuid.
ValidationContext
Everything a Rule needs to evaluate one attribute (BLUEPRINT_V2 §7.4.1).
ValidationMessages
Default validation messages (Laravel lang/en/validation.php parity) with an Indonesian translation as the second bundled locale.
Validator
Validates a map of input against rules (BLUEPRINT_V2 §7.4).

Extension Types

ValidatedData
Validated input with typed accessors (ADR-011). Only attributes that had rules are included (Laravel $request->validated() parity).

Extensions

RuleChain on Rule
Starts a RuleBuilder from any rule: Rules.required().email().

Constants

laravelImplicitRules → const Set<String>
Laravel's Validator::$implicitRules (laravel/framework 8 to 13, the same list), by rule name: a failure of one of these ends the validation of its attribute. prohibited is not one of them.

Functions

isEmptyValue(Object? value) → bool
Whether value counts as empty for required (Laravel semantics).
parseDate(Object? value) → DateTime?
Parses ISO-8601 dates/datetimes and yyyy-MM-dd.
phpDateMatchesFormat(String value, String format) → bool
Laravel's date_format check (ValidatesAttributes::validateDateFormat, laravel/framework v8.83.27 to v13.38.0): value passes when PHP's DateTime::createFromFormat('!' . $format, $value, UTC) reads it and formatting the result with format gives value back exactly, so 2026-02-30 fails Y-m-d (it overflows to March) and 2026-1-5 fails Y-m-d but passes Y-n-j.
rulesToJsonSchema(Map<String, Object> rules) → Map<String, Object?>
Converts validation rules (the map given to request.validate or a FormRequest) into a JSON Schema object (OpenAPI 3.1 dialect), so API documents and generated clients describe exactly what the server validates:
sizeOf(Object? value, {bool numeric = false}) → num?
Size of a value Laravel-style: numbers by value, strings by rune count, collections by length. null for unsupported types. Uploaded files by size in kilobytes, as Laravel measures them.

Typedefs

QueryConstraint = Object? Function(QueryBuilder query)
A condition added to the query of UniqueRule or ExistsRule: Rules.unique('users').where((q) => q.where('active', true)).

Exceptions / Errors

ValidationException
Thrown when validation fails; rendered as a Laravel-compatible 422: {"message": "...", "errors": {"field": ["..."]}}.