What's new in 1.0
1.0 is a breaking release. This page lists what is new; Upgrading to 1.0 lists what changed. The full changelogs are in the repository: luthor and luthor_generator.
Runtime
Section titled “Runtime”Typed output. Validators are generic over their output. l.int().required() validates to an int, l.list(l.string().required()) to a List<String>, with no cast and no generated code. How validators work.
One result type. validate returns ValidationResult<T>, either ValidationSuccess(data) or ValidationFailure(input, issues). messages, errors, getError and getErrors are on every result, empty on success. Results and issues.
Issues with codes. Each problem is a ValidationIssue with an IssueCode, a path, a message, params and a field name. Switch on the code instead of parsing text. ValidationIssue and IssueCode.
A flat error map with real paths. errors is keyed by error path: address.city, items.1.qty, scores.alice. List elements report at their index, map values at their key, and object-level errors at ''. Errors and error paths.
Modifiers in any order. Every modifier returns the validator’s own type, so l.string().required().min(3) compiles. Optional by default.
l.union(). A value that passes any one of several validators, with every option’s issues kept in the failure. l.union().
l.oneOf(). A fixed list of allowed values, which is also how the generator validates enums. l.oneOf().
Unknown keys. Schemas strip keys they do not declare. .passthrough() keeps them, .strict() reports them. Schemas.
.finite(). Rejects NaN and infinity on l.double() and l.num(). .finite().
regex(RegExp). The pattern is a RegExp, so flags apply and a bad pattern fails where it is written. .regex().
Message builders. messageBuilder: receives the issue, and l.messageBuilder sets one builder for every message, for translation. Message builders.
l.maxDepth. A nesting limit, default 512, that turns a hostile deep payload into a tooDeep issue instead of a stack overflow. Max depth.
l.file(accept:). Accept package types such as XFile as files, with a structural check that survives minified web builds. l.file().
Typed custom validators. .custom() and .customWithSchema() receive the typed value, never null, and SchemaData gives a schema custom validator the sibling fields plus root. Custom validators.
Recursion that validates. Schemas built with forwardRef() validate every level, including mutual recursion. forwardRef().
No dependencies. luthor dropped meta; it depends on nothing.
Generator
Section titled “Generator”Enums. An enum field generates l.oneOf([...]) with the serialized values, honouring @JsonValue, @JsonEnum, @MappableEnum and @MappableValue. Supported field types.
More types. Set, Iterable, Uri, Object, and map keys of type int, double, num, BigInt and enums. Supported field types.
Annotations on fields. Validation annotations are read from fields as well as constructor parameters, including fields reached through super. parameters. Annotations.
Serializer awareness. fieldRename, @JsonKey(name:), @MappableField(key:), @MappableClass(caseStyle:), constructor defaults, @JsonKey(defaultValue:), includeFromJson: false, converters, and the constructor the serializer uses. What gets generated.
$key in error keys. A nested model field in ErrorKeys is a record with a $key for its own path. Schema keys and error keys.
No build.yaml. The builder applies the combining builder itself, so plain classes and dart_mappable projects get a .g.dart without json_serializable. Models without freezed.
Forward references everywhere. Every nested schema reference is wrapped in forwardRef(). @luthorForwardRef is deprecated; remove it.
Clear failures. Unions, generic models, unsupported types and annotations on the wrong field type fail generation with an error naming the class and field, instead of generating code that skipped validation. Supported field types.
@isIp. A constant for @IsIp(). .ip().
@IsFile on any type. A field typed as a package class such as MultipartFile, or a list of one, generates l.file(accept:) instead of failing generation. l.file().
Analyzer 10 to 14. The generator resolves on every Flutter release from 3.41 onwards. Installation.
Agents
Section titled “Agents”A skill for coding agents. npx skills add exaby73/luthor installs a skill that teaches agents the Luthor API and code generation. Use Luthor with AI coding agents.