.passthrough()
Returns a copy of the schema that copies keys it does not declare into the output, without validating them. Non-string keys are converted with toString(). The default is to strip unknown keys. Only SchemaValidator has this method.
Signature
Section titled “Signature”SchemaValidator<O> passthrough()Code none. Default message: Adds no validation.
Code generation
Section titled “Code generation”The generator emits .passthrough() when it cannot name every key the serializer may read: a field with @JsonKey(readValue:), a private field with @JsonKey(includeFromJson: true), or a @MappableClass(hook:).
Example
Section titled “Example”final user = l.schema({'name': l.string().required()}).passthrough();final SchemaValidator $EventSchema = l .schema({...}) .passthrough() .withName("Event");l.schema({'name': l.string().required()}).passthrough().validate(input)+1-1- valid:
{'name': 'Ada', 'role': 'admin'} - invalid:
{'role': 'admin'}
Compare the three behaviours on the same input:
ValidationSuccess(data: {name: Ada})ValidationSuccess(data: {name: Ada, role: admin})ValidationFailure(errors: {role: [role is not an allowed key]})role is not an allowed key