Various schemas that are useful throughout the app.
Various schemas that are useful throughout the app.
(api-error-message schema)
Extract the API error messages attached to a schema, if any. This functionality is fairly sophisticated:
(api-error-message (s/maybe (non-empty [NonBlankString]))) ;; -> "value may be nil, or if non-nil, value must be an array. Each value must be a non-blank string. The array cannot be empty."
Extract the API error messages attached to a schema, if any. This functionality is fairly sophisticated: (api-error-message (s/maybe (non-empty [NonBlankString]))) ;; -> "value may be nil, or if non-nil, value must be an array. Each value must be a non-blank string. The array cannot be empty."
(api-param api-param-name schema)
Return schema
with an additional api-param-name
key that will be used in the auto-generate documentation and in
error messages. This is important for situations where you want to bind a parameter coming in to the API to
something other than the snake_case
key it normally comes in as:
;; BAD -- Documentation/errors will tell you dimension-type
is wrong
[:is {{dimension-type :type} :body}]
{dimension-type DimensionType}
;; GOOD - Documentation/errors will mention correct param name, type
[:is {{dimension-type :type} :body}]
{dimension-type (su/api-param "type" DimensionType)}
Return `schema` with an additional `api-param-name` key that will be used in the auto-generate documentation and in error messages. This is important for situations where you want to bind a parameter coming in to the API to something other than the `snake_case` key it normally comes in as: ;; BAD -- Documentation/errors will tell you `dimension-type` is wrong [:is {{dimension-type :type} :body}] {dimension-type DimensionType} ;; GOOD - Documentation/errors will mention correct param name, `type` [:is {{dimension-type :type} :body}] {dimension-type (su/api-param "type" DimensionType)}
Schema for a string that is a valid representation of a boolean (either true
or false
).
Something that adheres to this schema is guaranteed to to work with Boolean/parseBoolean
.
Schema for a string that is a valid representation of a boolean (either `true` or `false`). Something that adheres to this schema is guaranteed to to work with `Boolean/parseBoolean`.
(distinct schema)
Add an additional constraint to schema
(presumably an array) that requires all elements to be distinct.
Add an additional constraint to `schema` (presumably an array) that requires all elements to be distinct.
Schema for a valid map of embedding params.
Schema for a valid map of embedding params.
(empty-or-distinct? coll)
True if coll
is either empty or distinct.
True if `coll` is either empty or distinct.
Validates entity type derivatives of :entity/*
. Allows strings or keywords
Validates entity type derivatives of `:entity/*`. Allows strings or keywords
Schema for a valid Field type (does it derive from :type/*
)?
Schema for a valid Field type (does it derive from `:type/*`)?
Like FieldType
(e.g. a valid derivative of :type/*
) but allows either a keyword or a string.
This is useful especially for validating API input or objects coming out of the DB as it is unlikely
those values will be encoded as keywords at that point.
Like `FieldType` (e.g. a valid derivative of `:type/*`) but allows either a keyword or a string. This is useful especially for validating API input or objects coming out of the DB as it is unlikely those values will be encoded as keywords at that point.
Schema representing an integer than must also be greater than or equal to zero.
Schema representing an integer than must also be greater than or equal to zero.
Schema representing an integer than must also be greater than zero.
Schema representing an integer than must also be greater than zero.
Schema for a string that can be parsed as an integer.
Something that adheres to this schema is guaranteed to to work with Integer/parseInt
.
Schema for a string that can be parsed as an integer. Something that adheres to this schema is guaranteed to to work with `Integer/parseInt`.
Schema for a string that can be parsed as an integer, and is greater than or equal to zero.
Something that adheres to this schema is guaranteed to to work with Integer/parseInt
.
Schema for a string that can be parsed as an integer, and is greater than or equal to zero. Something that adheres to this schema is guaranteed to to work with `Integer/parseInt`.
Schema for a string that can be parsed as an integer, and is greater than zero.
Something that adheres to this schema is guaranteed to to work with Integer/parseInt
.
Schema for a string that can be parsed as an integer, and is greater than zero. Something that adheres to this schema is guaranteed to to work with `Integer/parseInt`.
Schema for a string that is valid serialized JSON.
Schema for a string that is valid serialized JSON.
Schema for something that can be either a Keyword
or a String
.
Schema for something that can be either a `Keyword` or a `String`.
(non-empty schema)
Add an addditonal constraint to schema
(presumably an array) that requires it to be non-empty
(i.e., it must satisfy seq
).
Add an addditonal constraint to `schema` (presumably an array) that requires it to be non-empty (i.e., it must satisfy `seq`).
Schema for a string that cannot be blank.
Schema for a string that cannot be blank.
Schema representing an integer 0 or greater
Schema representing an integer 0 or greater
Schema representing a numeric value greater than zero. This allows floating point numbers and integers.
Schema representing a numeric value greater than zero. This allows floating point numbers and integers.
(with-api-error-message schema api-error-message)
Return schema
with an additional api-error-message
that will be used to explain the error if a parameter fails
validation.
Return `schema` with an additional `api-error-message` that will be used to explain the error if a parameter fails validation.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close