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,declinedand, with other,accepted_ifanddeclined_if(laravel/frameworkValidatesAttributes, 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,ltandlte: 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_equalanddate_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'svalidateDateFormat). - DateRule
-
date: see Rules.date. - DecimalRule
-
decimal:2anddecimal:0,4. - DependentRule
-
prohibited_if,prohibited_unlessandpresent_if. - DigitCountRule
-
min_digitsandmax_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_svgadds svg). - InRule
-
inandnot_in: see Rules.inList. - IntegerRule
-
integer: see Rules.integer. - IpRule
-
ip,ipv4andipv6: see Rules.ip. - JsonRule
-
json: see Rules.json. - ListRule
-
arrayfor a JSON array: see Rules.list. - LowercaseRule
-
lowercase: see Rules.lowercase. - MapRule
-
arrayfor 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:
nullvalues 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
-
regexandnot_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
nullon success or a message reference on failure: either a translation key such asmin.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 aconst-friendly Rule subclass that can be introspected for messages and OpenAPI hints. - SameRule
-
sameanddifferent: 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_listby the group of the name. The database here also knows old aliases such asAsia/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.phpparity) 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.prohibitedis not one of them.
Functions
-
isEmptyValue(
Object? value) → bool -
Whether
valuecounts as empty forrequired(Laravel semantics). -
parseDate(
Object? value) → DateTime? -
Parses ISO-8601 dates/datetimes and
yyyy-MM-dd. -
phpDateMatchesFormat(
String value, String format) → bool -
Laravel's
date_formatcheck (ValidatesAttributes::validateDateFormat, laravel/framework v8.83.27 to v13.38.0):valuepasses when PHP'sDateTime::createFromFormat('!' . $format, $value, UTC)reads it and formatting the result withformatgivesvalueback exactly, so2026-02-30failsY-m-d(it overflows to March) and2026-1-5failsY-m-dbut passesY-n-j. -
rulesToJsonSchema(
Map< String, Object> rules) → Map<String, Object?> -
Converts validation rules (the map given to
request.validateor aFormRequest) 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.
nullfor 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": ["..."]}}.