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
- AlphaDashRule
- AlphaNumRule
- AlphaRule
- AsciiRule
- BailRule
- Marker: stop validating the attribute after the first failure.
- BetweenRule
- BooleanRule
- ClosureRule
- ConfirmedRule
- DateCompareRule
- 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
- DigitsBetweenRule
- DigitsRule
- DistinctRule
- EmailRule
- EndsWithRule
- 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
- FilledRule
- FormRequest
-
Reusable authorization + validation for a request (Laravel
FormRequest). - ImageRule
-
image(jpg, jpeg, png, gif, bmp, webp;image:allow_svgadds svg). - InRule
- IntegerRule
- IpRule
- JsonRule
- ListRule
- LowercaseRule
- MapRule
- MaxRule
- MimesRule
-
mimes:jpg,png: the extension guessed from the content. - MimetypesRule
-
mimetypes:image/jpeg,video/*: the type detected from the content. - MinRule
- NullableRule
-
Marker:
nullvalues skip the remaining rules. - NumericRule
- PasswordRule
- PresentRule
- ProhibitedRule
- RegexRule
- RequiredIfRule
- RequiredRule
- RequiredUnlessRule
- RequiredWithoutRule
- RequiredWithRule
- 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
- SizeRule
- SometimesRule
- Marker: validate only when the attribute is present.
- StartsWithRule
- StringRule
- UlidRule
- UniqueRule
-
unique:table,column,ignore,idColumn— queries the active connection (joining any Zone transaction). - UppercaseRule
- UrlRule
- UuidRule
- 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.
Exceptions / Errors
- ValidationException
-
Thrown when validation fails; rendered as a Laravel-compatible
422:{"message": "...", "errors": {"field": ["..."]}}.