JsonSchema class
Constructed with a json schema, either as string or Map. Validation of the schema itself is done on construction. Any errors in the schema result in a FormatException being thrown.
Properties
- additionalItemsBool → bool?
-
Whether additional items are allowed.
no setter
- additionalItemsSchema → JsonSchema?
-
JsonSchema additional items should conform to.
no setter
- additionalPropertiesBool → bool?
-
Whether additional properties, other than those specified, are allowed.
no setter
- additionalPropertiesSchema → JsonSchema?
-
JsonSchema that additional properties must conform to.
no setter
-
allOf
→ List<
JsonSchema> -
A List<JsonSchema> which the value must conform to all of.
no setter
- anchor → String?
-
A name used to reference a JsonSchema object.
no setter
-
anyOf
→ List<
JsonSchema> -
A List<JsonSchema> which the value must conform to at least one of.
no setter
- comment → String?
-
Description of the JsonSchema.
no setter
- constValue → dynamic
-
Const value of the JsonSchema.
no setter
- contains → JsonSchema?
-
JsonSchema definition that at least one item must match to be valid.
no setter
- contentEncoding → String?
-
Description of the JsonSchema.
no setter
- contentMediaType → String?
-
Description of the JsonSchema.
no setter
- contentSchema → String?
-
Description of the JsonSchema.
no setter
-
customAttributeValidators
→ Map<
String, ValidationContext Function(ValidationContext, Object)> -
The set of functions to validate custom keywords.
no setter
-
customFormats
→ Map<
String, ValidationContext Function(ValidationContext, String)> -
The set of functions to validate custom formats.
no setter
- defaultValue → dynamic
-
Default value of the JsonSchema.
no setter
-
definitions
→ Map<
String, JsonSchema> -
Included JsonSchema definitions.
no setter
-
defs
→ Map<
String, JsonSchema> -
Included JsonSchema $defs.
no setter
- deprecated → bool?
-
Whether the JSON Schema is deprecated.
no setter
- description → String?
-
Description of the JsonSchema.
no setter
- dynamicAnchor → String?
-
A name used to reference a JsonSchema object.
no setter
- dynamicRef → Uri?
-
A DynamicRef to the URI of the JsonSchema.
no setter
- elseSchema → JsonSchema?
-
A JsonSchema used for validataion if the schema doesn't validate against the 'if' schema.
no setter
- enumValues → List?
-
Possible values of the JsonSchema.
no setter
- examples → List
-
List of example instances for the JsonSchema.
no setter
- exclusiveMaximum → num?
-
The value of the exclusiveMaximum for the JsonSchema, if any exists.
no setter
- exclusiveMinimum → num?
-
The value of the exclusiveMaximum for the JsonSchema, if any exists.
no setter
- format → String?
-
Pre-defined format (i.e. date-time, email, etc) of the JsonSchema value.
no setter
- hasConst → bool
-
Whether or not const is set, we need this since const can be null and valid.
no setter
- hasExclusiveMaximum → bool
-
Whether the maximum of the JsonSchema is exclusive.
no setter
- hasExclusiveMinimum → bool
-
Whether the minimum of the JsonSchema is exclusive.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → Uri?
-
ID of the JsonSchema.
no setter
- ifSchema → JsonSchema?
-
A JsonSchema that conditionally decides if validation should be performed against the 'then' or 'else' schema.
no setter
- items → JsonSchema?
-
Single JsonSchema sub items of this JsonSchema must conform to.
Note: This has subtly changed in draft 2020.
no setter
-
itemsList
→ List<
JsonSchema?> ? -
Ordered list of JsonSchema which the value of the same index must conform to.
no setter
- maxContains → int?
-
The maximum number of elements in the list that are valid against the schema for contains
no setter
- maximum → num?
-
Maximum value of the JsonSchema value.
no setter
- maxItems → int?
-
The maximum number of items allowed.
no setter
- maxLength → int?
-
Maximum length of the JsonSchema value.
no setter
- maxProperties → int?
-
The maximum number of properties allowed.
no setter
-
metaschemaVocabulary
→ Map<
Uri, bool> ? -
The vocabularies defined by the metaschema of this JsonSchema.
no setter
- minContains → int?
-
The minimum number of elements in the list that are valid against the schema for contains
no setter
- minimum → num?
-
Minimum value of the JsonSchema value.
no setter
- minItems → int?
-
The minimum number of items allowed.
no setter
- minLength → int?
-
Minimum length of the JsonSchema value.
no setter
- minProperties → int
-
The minimum number of properties allowed.
no setter
- multipleOf → num?
-
The number which the value of the JsonSchema must be a multiple of.
no setter
- notSchema → JsonSchema?
-
A JsonSchema which the value must NOT be.
no setter
-
oneOf
→ List<
JsonSchema> -
A List<JsonSchema> which the value must conform to at least one of.
no setter
- parent → JsonSchema?
-
The parent JsonSchema for this JsonSchema.
no setter
- path → String?
-
The path of the JsonSchema within the root JsonSchema.
no setter
- pattern → RegExp?
-
The regular expression the JsonSchema value must conform to.
no setter
-
patternProperties
→ Map<
RegExp, JsonSchema> -
Map of JsonSchemas for properties, based on RegExps keys.
no setter
-
prefixItems
→ List<
JsonSchema> ? -
Ordered list of JsonSchema which the value of the same index must conform to.
Used in draft2020-12
https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.1
no setter
-
properties
→ Map<
String, JsonSchema> -
Map of JsonSchemas for properties, by String key.
no setter
-
propertyDependencies
→ Map<
String, List< String> > -
Map of property dependencies by property name.
no setter
- propertyName → String?
-
Name of the property of the current JsonSchema within its parent.
no setter
- propertyNamesSchema → JsonSchema?
-
JsonSchema that property names must conform to.
no setter
- readOnly → bool
-
Whether the JSON Schema is read-only.
no setter
- recursiveAnchor → bool
-
Whether the JsonSchema is a recursive anchor point or not.
no setter
- recursiveRef → Uri?
-
RecursiveRef to the URI of the JsonSchema.
no setter
- ref → Uri?
-
Ref to the URI of the JsonSchema.
no setter
- requiredOnParent → bool
-
Whether the JsonSchema is required on its parent.
no setter
-
requiredProperties
→ List<
String> ? -
Properties that must be inclueded for the JsonSchema to be valid.
no setter
- root → JsonSchema?
-
The root JsonSchema for this JsonSchema.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schemaBool → bool?
-
JSON of the JsonSchema as a bool. Only this value or
_schemaMap
should be set, not both.no setter -
schemaDependencies
→ Map<
String, JsonSchema> -
Map of schema dependencies by property name.
no setter
- schemaMap → Map?
-
JSON of the JsonSchema as a Map. Only this value or
_schemaBool
should be set, not both.no setter - schemaVersion → SchemaVersion
-
JSON Schema version used.
no setter
- thenSchema → JsonSchema?
-
A JsonSchema used for validation if the schema also validates against the 'if' schema.
no setter
- title → String?
-
Title of the JsonSchema.
no setter
- type → SchemaType?
-
Single allowable type for the JsonSchema.
no setter
-
typeList
→ List<
SchemaType?> ? -
List of allowable types for the JsonSchema.
no setter
- unevaluatedItems → JsonSchema?
-
JsonSchema of unevaluated items
no setter
- unevaluatedProperties → JsonSchema?
-
JsonSchema that unevaluated properties must conform to.
no setter
- uniqueItems → bool
-
Whether the items in the list must be unique.
no setter
-
vocabulary
→ Map<
Uri, bool> ? -
The vocabularies defined by this JsonSchema.
no setter
- writeOnly → bool
-
Whether the JSON Schema is write-only.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
propertyRequired(
String? property) → bool - Whether a given property is required for the JsonSchema instance to be valid.
-
resolveDynamicAnchor(
String dynamicAnchor, {JsonSchema? dynamicParent}) → JsonSchema? - Get a JsonSchema from the dynamicParent with the given anchor. Returns null if none exists.
-
resolvePath(
Uri? path) → JsonSchema - Get a nested JsonSchema from a path.
-
toJson(
) → String - JSON string represenatation of the schema.
-
toString(
) → String -
A string representation of this object.
override
-
validate(
dynamic instance, {bool parseJson = false, bool? validateFormats}) → ValidationResults -
Validate
instance
against this schema, returning the result with information about any validation errors or warnings that occurred. -
validateWithResults(
dynamic instance, {bool parseJson = false, bool? validateFormats}) → ValidationResults
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
create(
Object schema, {SchemaVersion? schemaVersion, Uri? fetchedFromUri, RefProvider? refProvider, List< CustomVocabulary> ? customVocabularies, Map<String, ValidationContext Function(ValidationContext context, String instanceData)> customFormats = const {}}) → JsonSchema - Create a schema from JSON data.
-
createAsync(
Object? schema, {SchemaVersion? schemaVersion, Uri? fetchedFromUri, RefProvider? refProvider, List< CustomVocabulary> ? customVocabularies, Map<String, ValidationContext Function(ValidationContext context, String instanceData)> customFormats = const {}}) → Future<JsonSchema> - Create a schema from a JSON data.
-
createFromUrl(
String schemaUrl, {SchemaVersion? schemaVersion, List< CustomVocabulary> ? customVocabularies, Map<String, ValidationContext Function(ValidationContext context, String? instanceData)> customFormats = const {}}) → Future<JsonSchema> - Create a schema from a URL.
-
empty(
{SchemaVersion schemaVersion = SchemaVersion.defaultVersion}) → JsonSchema - Create an empty schema.