Schema extension type
A JSON Schema object defining the any kind of property.
See the subtypes ObjectSchema, ListSchema, StringSchema, NumberSchema, IntegerSchema, BooleanSchema, NullSchema.
To get an instance of a subtype, you should inspect the type as well as check for any schema combinators (allOf, anyOf, oneOf, not), as both may be present.
If a type is provided, it applies to all sub-schemas, and you can cast all the sub-schemas directly to the specified type from the parent schema.
See https://json-schema.org/understanding-json-schema/reference for the full specification.
Note: Only a subset of the json schema spec is supported by these types,
if you need something more complex you can create your own
Map<String, Object?>
and cast it to Schema (or ObjectSchema) directly.
- on
- Implementers
- Available extensions
Constructors
-
Schema.combined({JsonType? type, String? title, String? description, List<
Schema> ? allOf, List<Schema> ? anyOf, List<Schema> ? oneOf, List<Schema> ? not}) -
A combined schema, see
https://json-schema.org/understanding-json-schema/reference/combining#schema-composition
factory
-
Schema.fromMap(Map<
String, Object?> _value)
Properties
-
allOf
→ List<
Schema> ? -
Schema combinator that requires all sub-schemas to match.
no setter
-
anyOf
→ List<
Schema> ? -
Schema combinator that requires at least one of the sub-schemas to match.
no setter
- description → String?
-
A description of this schema.
no setter
-
not
→ List<
Schema> ? -
Schema combinator that requires none of the sub-schemas to match.
no setter
-
oneOf
→ List<
Schema> ? -
Schema combinator that requires exactly one of the sub-schemas to match.
no setter
- title → String?
-
A title for this schema, should be short.
no setter
- type → JsonType?
-
The JsonType of this schema, if present.
no setter
Methods
-
validate(
Object? data) → List< ValidationError> -
Available on Schema, provided by the SchemaValidation extension
Validates the givendata
against this schema.
Constants
- bool → const BooleanSchema Function({String? description, String? title})
- Alias for BooleanSchema.new.
- int → const IntegerSchema Function({String? description, int? exclusiveMaximum, int? exclusiveMinimum, int? maximum, int? minimum, num? multipleOf, String? title})
- Alias for IntegerSchema.new.
-
list
→ const ListSchema Function({String? description, Schema? items, int? maxItems, int? minItems, List<
Schema> ? prefixItems, String? title, bool? unevaluatedItems, bool? uniqueItems}) - Alias for ListSchema.new.
- nil → const NullSchema Function({String? description, String? title})
- Alias for NullSchema.new.
- num → const NumberSchema Function({String? description, num? exclusiveMaximum, num? exclusiveMinimum, num? maximum, num? minimum, num? multipleOf, String? title})
- Alias for NumberSchema.new.
-
object
→ const ObjectSchema Function({Object? additionalProperties, String? description, int? maxProperties, int? minProperties, Map<
String, Schema> ? patternProperties, Map<String, Schema> ? properties, StringSchema? propertyNames, List<String> ? required, String? title, bool? unevaluatedProperties}) - Alias for ObjectSchema.new.
- string → const StringSchema Function({String? description, int? maxLength, int? minLength, String? pattern, String? title})
- Alias for StringSchema.new.