Schema class
A JSON Schema node parsed with the declared dialect (2020-12 by default).
The original JSON value is retained so unsupported annotations and future vocabulary keywords survive a load/serialize cycle. Both object and boolean schemas are supported. Use validate to validate an instance.
Constructors
-
Schema({required String type, List<
String> ? typeUnion, String? description, Map<String, Schema> ? properties, Schema? items, Object? additionalProperties, List<Object?> ? enum_, List<String> ? required, List<Schema> ? oneOf, List<Schema> ? anyOf, List<Schema> ? allOf, num? minimum, num? maximum, num? exclusiveMinimum, num? exclusiveMaximum, num? multipleOf, num? minLength, num? maxLength, String? pattern, String? format, num? minItems, num? maxItems, bool? uniqueItems, num? minProperties, num? maxProperties, Object? constValue = _schemaUnset, Object? defaultValue = _schemaUnset}) -
Creates a schema using the former convenience constructor.
factory
- Schema.fromJson(Object json, {SchemaResolver? resolver})
-
Creates a schema from any JSON Schema object or boolean schema.
factory
Properties
- additionalProperties → Object?
-
no setter
-
allOf
→ List<
Schema> ? -
no setter
-
anyOf
→ List<
Schema> ? -
no setter
- constValue → Object?
-
no setter
- defaultValue → Object?
-
no setter
- description → String?
-
no setter
-
enum_
→ List<
Object?> ? -
no setter
- exclusiveMaximum → num?
-
no setter
- exclusiveMinimum → num?
-
no setter
- format → String?
-
no setter
- hasConstValue → bool
-
no setter
- hasDefaultValue → bool
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasType → bool
-
no setter
- isBooleanSchema → bool
-
Whether this node is a boolean schema (
trueorfalse).no setter - items → Schema?
-
no setter
- maximum → num?
-
no setter
- maxItems → num?
-
no setter
- maxLength → num?
-
no setter
- maxProperties → num?
-
no setter
- minimum → num?
-
no setter
- minItems → num?
-
no setter
- minLength → num?
-
no setter
- minProperties → num?
-
no setter
- multipleOf → num?
-
no setter
-
oneOf
→ List<
Schema> ? -
no setter
- pattern → String?
-
no setter
-
properties
→ Map<
String, Schema> ? -
no setter
- rawSchema → Object
-
An immutable view of the original JSON Schema value.
no setter
-
required
→ List<
String> ? -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → String
-
no setter
-
typeUnion
→ List<
String> ? -
no setter
- uniqueItems → bool?
-
no setter
Methods
-
isValid(
Object? instance, {bool? validateFormats}) → bool -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Object - The original schema value, preserving references and all keywords.
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
Object? instance, {bool? validateFormats}) → SchemaValidationResult - Validates an instance and returns structured errors and warnings.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String keyword) → Object? -
Returns a keyword's original value, or
nullif it is absent or null.