NullableSchema<O> class
The value may be null. Made by .nullable().
- Inheritance
-
- Object
- Schema<
O?> - BaseSchema<
O?> - NullableSchema
- Mixed-in types
-
- FluentSchema<
NullableSchema< O> , O?>
- FluentSchema<
Constructors
-
NullableSchema(Schema<
O> inner)
Properties
- bails ↔ bool
-
truewhen the first failed rule stops the other rules. Set with.bail().getter/setter pairinherited - description ↔ String?
-
Text for docs. Set with
.describe().getter/setter pairinherited -
examples
→ List<
Object?> -
Example values for docs. Set with
.example().finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
-
inner
→ Schema<
O> -
The wrapped schema.
final
- isAsync → bool
-
truewhen this schema or a child has async rules.no setteroverride - isOptional → bool
-
truewhen the value may be missing in an object.no setteroverride -
rules
→ List<
Rule< O?> > -
Rules that run after the type check.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- vendor → String
-
Name of the library that made the schema. Dox schemas use
dox.no setterinherited - version → int
-
Version of the Standard Schema interface. Always
1.no setterinherited
Methods
-
accepted(
{String? message}) → NullableSchema< O> -
Must be
true,1,'1','true','yes'or'on'.v.bool()takes onlytrueandfalse: usev.coerce.bool().accepted()for form words (any case), orv.string()/v.any()to check the exact words.inherited -
addRequiredIssue(
Object? input, ParseState state, List< Object> path) → void -
Add the
requiredissue.inherited -
addTypeIssue(
{required String code, required String fallback, required Object? input, required ParseState state, required List< Object> path}) → void -
Add a wrong type issue, like "must be a string".
inherited
-
bail(
) → NullableSchema< O> -
Stop at the first failed rule of this schema, so the value gets
one issue. It counts for the rules of this schema
only, wherever it is in the chain. A wrapper like
.optional()and the fields of an object or the items of a list keep their own setting. So.optional().bail()does nothing for the rules inside.optional(): call.bail()before the wrapper.inherited -
confirmed(
{String? other, String? message}) → NullableSchema< O> -
The key
<field>_confirmation(orother) in the same object must have the same value.inherited -
copyBaseInto<
T extends BaseSchema< (O> >T target) → T -
Copy rules and meta data from this schema into
target.inherited -
copySchema(
) → NullableSchema< O> -
Make a copy with the same settings. Used by the fluent methods.
override
-
declined(
{String? message}) → NullableSchema< O> -
Must be
false,0,'0','false','no'or'off'. See accepted for the schema to use.inherited -
defaultTo(
O? value) → DefaultSchema< O?> -
Use
valuewhen the input is missing. (defaultis a reserved word in Dart.)inherited -
describe(
String text) → NullableSchema< O> -
Add a description for docs (JSON Schema
description).inherited -
different(
String other, {String? message}) → NullableSchema< O> -
Must not equal the key
otherin the same object.inherited -
example(
Object? value) → NullableSchema< O> -
Add an example value for docs (JSON Schema
examples).inherited -
excludeIf(
String other, Object? value) → ExcludeSchema< O?> -
Leave the key out of the output, with no check, when the key
otherin the same object hasvalue(or one of the values, whenvalueis a list). Whenotheris missing, the key is not left out.otheris a key of the same object, not a dotted path. It works on a field ofv.object()only. Anywhere else it does nothing. The cross-field rules of other fields, likesameorrequiredIf, still read the raw value of a skipped field.inherited -
excludeUnless(
String other, Object? value) → ExcludeSchema< O?> -
Leave the key out of the output, with no check, unless the key
otherin the same object hasvalue. A missingothercounts asnull. See excludeIf.inherited -
jsonSchemaBase(
) → Map< String, dynamic> -
JSON Schema keys for the type, like
{'type': 'string'}.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable(
) → NullableSchema< O?> -
The value may be
null. It must still be present in an object.inherited -
nullish(
) → OptionalSchema< O?> -
The value may be missing or
null.inherited -
optional(
) → OptionalSchema< O?> -
The value may be missing.
nullis still not allowed.inherited -
parse(
Object? input, {MessageResolver? messages}) → O? -
Return the typed output or throw
ValidationException.inherited -
parseAsync(
Object? input, {MessageResolver? messages}) → Future< O?> -
Async version of parse. Needed for async rules.
inherited
-
parseType(
Object? input, ParseState state, List< Object> path) → Object? -
Check the type and return the output, or invalid.
inputis nevernullor undefined here.override -
parseTypeAsync(
Object? input, ParseState state, List< Object> path) → Future<Object?> -
Async version of parseType. Container schemas override it.
inherited
-
parseValue(
Object? input, ParseState state, List< Object> path) → Object? -
Parse one value: check missing values, the type, then the rules.
override
-
parseValueAsync(
Object? input, ParseState state, List< Object> path) → Future<Object?> -
Async version of parseValue.
override
-
refine(
bool check(O? value), {String? message, String code = 'custom', List< Object> path = const <Object>[]}) → NullableSchema<O> -
Add a one-off check.
pathis added to the issue path, which is handy for object checks like "passwords must match".inherited -
refineAsync(
Future< bool> check(O? value), {String? message, String code = 'custom', List<Object> path = const <Object>[]}) → NullableSchema<O> -
Add an async one-off check, like "email is unique".
Use
parseAsyncwith it.inherited -
runRules(
Object? output, int issuesBefore, ParseState state, List< Object> path) → Object? -
Run rules on
output. Skipped when the value already has issues.inherited -
runRulesAsync(
Object? output, int issuesBefore, ParseState state, List< Object> path) → Future<Object?> -
Async version of runRules.
inherited
-
safeParse(
Object? input, {MessageResolver? messages}) → ParseResult< O?> -
Return a ParseResult. It never throws for bad input.
inherited
-
safeParseAsync(
Object? input, {MessageResolver? messages}) → Future< ParseResult< O?> > -
Async version of safeParse.
inherited
-
same(
String other, {String? message}) → NullableSchema< O> -
Must equal the key
otherin the same object.inherited -
superRefine(
void check(O? value, RuleContext context)) → NullableSchema< O> -
Add a check that can add many issues with
context.addIssue().inherited -
superRefineAsync(
Future< void> check(O? value, RuleContext context)) → NullableSchema<O> -
Async version of superRefine.
inherited
-
toJsonSchema(
) → Map< String, dynamic> -
JSON Schema (draft 2020-12, OpenAPI 3.1) for this schema.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transform<
T> (T transformer(O? value)) → TransformSchema< O?, T> -
Change the output after it passes validation.
inherited
-
use(
Rule< O?> rule) → NullableSchema<O> -
Add a reusable Rule.
inherited
-
validate(
Object? value) → FutureOr< StandardResult< O?> > -
Standard Schema entry point.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited