TypeRule class final

Validates the Dart runtime type of a value against a JSON Schema type.

Supports both the string form ("type": "string") and the array form ("type": ["string", "null"]) as required by JSON Schema spec ยง6.1.1. In the array form the value is valid if it matches any of the listed types (logical OR).

Inheritance

Constructors

TypeRule(String type)
Creates a rule that accepts a single type string.
TypeRule.fromList(List<String> types)
Creates a rule that accepts any of types (array form).

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
types List<String>
The JSON Schema type strings accepted by this rule.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
validate(dynamic value, String path) List<SchemaViolation>
Validates value at path and returns every violation found.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited