ObjectSchema class
Schema for a map with known keys. Made by v.object().
The output is a new Map<String, dynamic>.
- Inheritance
- Mixed-in types
-
- FluentSchema<
ObjectSchema, Map< String, dynamic> >
- FluentSchema<
Constructors
-
ObjectSchema(Map<
String, Schema< shape, {UnknownKeys unknownKeys = UnknownKeys.strip})Object?> >
Properties
- 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
- 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 setterinherited -
rules
→ List<
Rule< Map< >String, dynamic> > -
Rules that run after the type check.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shape
→ Map<
String, Schema< Object?> > -
Schema for each key.
final
- unknownKeys → UnknownKeys
-
What to do with keys that are not in shape.
final
- 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
-
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
-
copyBaseInto<
T extends BaseSchema< (O> >T target) → T -
Copy rules and meta data from this schema into
target.inherited -
copySchema(
) → ObjectSchema -
Make a copy with the same settings. Used by the fluent methods.
override
-
defaultTo(
Map< String, dynamic> value) → DefaultSchema<Map< String, dynamic> > -
Use
valuewhen the input is missing. (defaultis a reserved word in Dart.)inherited -
describe(
String text) → ObjectSchema -
Add a description for docs (JSON Schema
description).inherited -
example(
Object? value) → ObjectSchema -
Add an example value for docs (JSON Schema
examples).inherited -
extend(
Map< String, Schema< more) → ObjectSchemaObject?> > - Add or replace keys.
-
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< Map< String, dynamic> > -
The value may be
null. It must still be present in an object.inherited -
nullish(
) → OptionalSchema< Map< String, dynamic> ?> -
The value may be missing or
null.inherited -
omit(
List< String> keys) → ObjectSchema -
Remove
keys. -
optional(
) → OptionalSchema< Map< String, dynamic> > -
The value may be missing.
nullis still not allowed.inherited -
parse(
Object? input, {MessageResolver? messages}) → Map< String, dynamic> -
Return the typed output or throw
ValidationException.inherited -
parseAsync(
Object? input, {MessageResolver? messages}) → Future< Map< String, dynamic> > -
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.
override
-
parseValue(
Object? input, ParseState state, List< Object> path) → Object? -
Parse one value: check missing values, the type, then the rules.
inherited
-
parseValueAsync(
Object? input, ParseState state, List< Object> path) → Future<Object?> -
Async version of parseValue.
inherited
-
partial(
) → ObjectSchema - Make every key optional. Good for PATCH requests.
-
passthrough(
) → ObjectSchema - Keep unknown keys in the output.
-
pick(
List< String> keys) → ObjectSchema -
Keep only
keys. -
refine(
bool check(Map< String, dynamic> value), {String? message, String code = 'custom', List<Object> path = const <Object>[]}) → ObjectSchema -
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(Map<String, dynamic> value), {String? message, String code = 'custom', List<Object> path = const <Object>[]}) → ObjectSchema -
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< Map< String, dynamic> > -
Return a ParseResult. It never throws for bad input.
inherited
-
safeParseAsync(
Object? input, {MessageResolver? messages}) → Future< ParseResult< Map< >String, dynamic> > -
Async version of safeParse.
inherited
-
strict(
) → ObjectSchema - Unknown keys are an error.
-
strip(
) → ObjectSchema - Drop unknown keys from the output (the default).
-
superRefine(
void check(Map< String, dynamic> value, RuleContext context)) → ObjectSchema -
Add a check that can add many issues with
context.addIssue().inherited -
superRefineAsync(
Future< void> check(Map<String, dynamic> value, RuleContext context)) → ObjectSchema -
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(Map< String, dynamic> value)) → TransformSchema<Map< String, dynamic> , T> -
Change the output after it passes validation.
inherited
-
use(
Rule< Map< rule) → ObjectSchemaString, dynamic> > -
Add a reusable Rule.
inherited
-
validate(
Object? value) → FutureOr< StandardResult< Map< >String, dynamic> > -
Standard Schema entry point.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited