Validations based on annotations.
Validations based on annotations.
(make-validation-result schema value path kind args)
Returns a standard validation result.
schema
- the schema of the attribute. optional.
value
- the value of the attribute. optional
path
- a sequence of attribute ids representing the location where the validation
failed.
kind
- keyword indicating the kind of failure.
args
- extra information for certain kinds of failures
Returns a standard validation result. `schema` - the schema of the attribute. optional. `value` - the value of the attribute. optional `path` - a sequence of attribute ids representing the location where the validation failed. `kind` - keyword indicating the kind of failure. `args` - extra information for certain kinds of failures
Standard options passed to validate-object
if not overridden.
Standard options passed to `validate-object` if not overridden.
A standard set of type validations used by validate-object
. This includes validation
for :string
, :boolean
, :number
, :date
, :uuid
, :url
, and :bag
types.
A standard set of type validations used by `validate-object`. This includes validation for `:string`, `:boolean`, `:number`, `:date`, `:uuid`, `:url`, and `:bag` types.
(type-name x)
Returns the simple name of the class of x
. For e.g., (type-name true) will return
"boolean".
Returns the simple name of the class of `x`. For e.g., (type-name true) will return "boolean".
(valid-url? s)
Returns logical true if s
is a valid URL string
Returns logical true if `s` is a valid URL string
(valid-uuid? s)
Returns logical true if string s
is a valid UUID in its canonical textual
representation.
Returns logical true if string `s` is a valid UUID in its canonical textual representation.
(validate-object schema obj)
(validate-object schema obj opts)
(validate-object path
schema
obj
{:keys [make-result fail-on-unsupported-attributes?] :as opts})
Validate an object given its schema. Returns a sequence of as produced by the
make-result
function. Returns an empty sequence if there are no validation
errors/warnings.
path
- a vector of the path elements to be used in error messages. Use [] at top
level.
schema
- the schema to validate against.
obj
- the object to validate
opts
- options for validation, this should be a map with the following keys
:make-result
- a function that takes the schema, the attribute value, the attribute
path, an error kind with optional arguments and returns a validation result as a
vector. See make-validation-result
for an example.
:type-checks
- a map from type names to functions validating the conformance of a
value to those types. See type-checks
for an example.
:fail-on-unsupported-attributes?
- if true an error will be reported if the obj
contains an attribute that is not defined in schema
.
Validate an object given its schema. Returns a sequence of as produced by the `make-result` function. Returns an empty sequence if there are no validation errors/warnings. `path` - a vector of the path elements to be used in error messages. Use [] at top level. `schema` - the schema to validate against. `obj` - the object to validate `opts` - options for validation, this should be a map with the following keys `:make-result` - a function that takes the schema, the attribute value, the attribute path, an error kind with optional arguments and returns a validation result as a vector. See `make-validation-result` for an example. `:type-checks` - a map from type names to functions validating the conformance of a value to those types. See `type-checks` for an example. `:fail-on-unsupported-attributes?` - if true an error will be reported if the `obj` contains an attribute that is not defined in `schema`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close