NumberChecks<S extends BaseSchema<N>, N extends num> mixin
Shared number methods for IntSchema and NumSchema.
Properties
-
bails
↔ bool
-
true when 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
-
isAsync
→ bool
-
true when this schema or a child has async rules.
no setterinherited
-
isOptional
→ bool
-
true when the value may be missing in an object.
no setterinherited
-
rules
→ List<Rule<N>>
-
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})
→ S
-
Must be
true, 1, '1', 'true', 'yes' or 'on'.
v.bool() takes only true and false: use
v.coerce.bool().accepted() for form words (any case), or
v.string() / v.any() to check the exact words.
inherited
-
addRequiredIssue(Object? input, ParseState state, List<Object> path)
→ void
-
Add the
required issue.
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()
→ S
-
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
-
between(num min, num max, {String? message})
→ S
-
From
min to max.
-
confirmed({String? other, String? message})
→ S
-
The key
<field>_confirmation (or other) 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()
→ BaseSchema<N>
-
Make a copy with the same settings. Used by the fluent methods.
inherited
-
declined({String? message})
→ S
-
Must be
false, 0, '0', 'false', 'no' or 'off'.
See accepted for the schema to use.
inherited
-
defaultTo(N value)
→ DefaultSchema<N>
-
Use
value when the input is missing.
(default is a reserved word in Dart.)
inherited
-
describe(String text)
→ S
-
Add a description for docs (JSON Schema
description).
inherited
-
different(String other, {String? message})
→ S
-
Must not equal the key
other in the same object.
inherited
-
example(Object? value)
→ S
-
Add an example value for docs (JSON Schema
examples).
inherited
-
excludeIf(String other, Object? value)
→ ExcludeSchema<N>
-
Leave the key out of the output, with no check, when the key
other in the same object has value (or one of the values, when
value is a list). When other is missing,
the key is not left out. other is a key of the same object, not a
dotted path. It works on a field of v.object() only. Anywhere
else it does nothing. The cross-field rules of other fields, like
same or requiredIf, still read the raw value of a skipped field.
inherited
-
excludeUnless(String other, Object? value)
→ ExcludeSchema<N>
-
Leave the key out of the output, with no check, unless the key
other in the same object has value.
A missing other counts as null. See excludeIf.
inherited
-
exists(String table, {String column = 'id', String? connection, String? message})
→ S
-
A row in
table has this value in column.
Needs parseAsync and a PresenceVerifier. A name that is not
plain throws an ArgumentError here.
-
gt(num value, {String? message})
→ S
-
Greater than
value.
-
gteField(String other, {String? message})
→ S
-
At least the key
other in the same object.
-
gtField(String other, {String? message})
→ S
-
Greater than the key
other in the same object.
A missing other fails.
-
jsonSchemaBase()
→ Map<String, dynamic>
-
JSON Schema keys for the type, like
{'type': 'string'}.
inherited
-
lt(num value, {String? message})
→ S
-
Less than
value.
-
lteField(String other, {String? message})
→ S
-
At most the key
other in the same object.
-
ltField(String other, {String? message})
→ S
-
Less than the key
other in the same object.
-
max(num value, {String? message})
→ S
-
At most
value.
-
min(num value, {String? message})
→ S
-
At least
value.
-
multipleOf(num factor, {String? message})
→ S
-
A multiple of
factor.
-
nonNegative({String? message})
→ S
-
Zero or more.
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable()
→ NullableSchema<N>
-
The value may be
null. It must still be present in an object.
inherited
-
nullish()
→ OptionalSchema<N?>
-
The value may be missing or
null.
inherited
-
optional()
→ OptionalSchema<N>
-
The value may be missing.
null is still not allowed.
inherited
-
parse(Object? input, {MessageResolver? messages})
→ N
-
Return the typed output or throw
ValidationException.
inherited
-
parseAsync(Object? input, {MessageResolver? messages})
→ Future<N>
-
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.
input is never null or undefined here.
inherited
-
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.
inherited
-
parseValueAsync(Object? input, ParseState state, List<Object> path)
→ Future<Object?>
-
Async version of parseValue.
inherited
-
positive({String? message})
→ S
-
Greater than zero.
-
refine(bool check(N value), {String? message, String code = 'custom', List<Object> path = const <Object>[]})
→ S
-
Add a one-off check.
path is added to the issue path, which is
handy for object checks like "passwords must match".
inherited
-
refineAsync(Future<bool> check(N value), {String? message, String code = 'custom', List<Object> path = const <Object>[]})
→ S
-
Add an async one-off check, like "email is unique".
Use
parseAsync with 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<N>
-
Return a ParseResult. It never throws for bad input.
inherited
-
safeParseAsync(Object? input, {MessageResolver? messages})
→ Future<ParseResult<N>>
-
Async version of safeParse.
inherited
-
same(String other, {String? message})
→ S
-
Must equal the key
other in the same object.
inherited
-
superRefine(void check(N value, RuleContext context))
→ S
-
Add a check that can add many issues with
context.addIssue().
inherited
-
superRefineAsync(Future<void> check(N value, RuleContext context))
→ S
-
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(N value))
→ TransformSchema<N, T>
-
Change the output after it passes validation.
inherited
-
unique(String table, {required String column, Object? ignore, String ignoreColumn = 'id', String? connection, String? message})
→ S
-
No row in
table has this value in column. ignore skips the
row where ignoreColumn equals it. column is required: it is
never taken from the input key.
Needs parseAsync and a PresenceVerifier.
-
use(Rule<N> rule)
→ S
-
Add a reusable Rule.
inherited
-
validate(Object? value)
→ FutureOr<StandardResult<N>>
-
Standard Schema entry point.
inherited