Validation fails with list of errors, one for each invalid leaf of the value object. When validation succeeds it also returns value being validated. Currently this value is the same as initial value, later version will allow options to be supplied in order to normalize value along the validation (e.g. apply defaults, remove additional properties, coerce types)
validate : ValidationOptions -> Ref.SchemataPool -> Json.Decode.Value -> Json.Schema.Definitions.Schema -> Json.Schema.Definitions.Schema -> Result (List Error) Json.Decode.Value
Validate value against schema
{ applyDefaults : Basics.Bool }
Validation options which allow to apply defaults (more options upcoming)
defaultOptions : ValidationOptions
Default validation options, applyDefaults = True
{ jsonPointer : JsonPointer
, details : ValidationError
}
Attempt to validate returns Result
with list of Error
instances as an Err
.
Validation errors with details. The rule of parametrized errors like Maximum
is that first parameter is always expected value, second parameter is actual value. Most of errors named after respective validation properties, only exception from this rule for cases like AlwaysFail
which doesn't have keyword (this is result of boolean schema false), or AdditionalPropertiesDisallowed
which represent subset of .additionalProperties
validation when its value equals to false
and additional property is present.
There are keywords in JSON Schema which don't have their dedicated error codes:
The reason for this is the nature of these errors is to go deeper into the nested Schema and Value.
Current implementation of validation only creates errors for leaves of the Value, not for nodes, e.g. if one of the properties fails a validation, error list will contain an error for the property but not for the object containing it. This decision is made to reduce noise in errors, since it is obvious that all the parent objects containing invalid properties are also invalid, and this information can be derived from json path if needed.
{ ns : String
, path : List String
}
Path in json value.
A few notes: