Liking cljdoc? Tell your friends :D

metabase.util.schema

Various schemas that are useful throughout the app.

Various schemas that are useful throughout the app.
raw docstring

api-error-messageclj

(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."
sourceraw docstring

api-paramclj

(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)}
sourceraw docstring

BooleanStringclj

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`.
sourceraw docstring

ComplexPasswordclj

Schema for a valid password of sufficient complexity.

Schema for a valid password of sufficient complexity.
sourceraw docstring

distinctclj

(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.
sourceraw docstring

Emailclj

Schema for a valid email string.

Schema for a valid email string.
sourceraw docstring

EmbeddingParamsclj

Schema for a valid map of embedding params.

Schema for a valid map of embedding params.
sourceraw docstring

empty-or-distinct?clj

(empty-or-distinct? coll)

True if coll is either empty or distinct.

True if `coll` is either empty or distinct.
sourceraw docstring

EntityTypeKeywordOrStringclj

Validates entity type derivatives of :entity/*. Allows strings or keywords

Validates entity type derivatives of `:entity/*`. Allows strings or keywords
sourceraw docstring

FieldTypeclj

Schema for a valid Field type (does it derive from :type/*)?

Schema for a valid Field type (does it derive from `:type/*`)?
sourceraw docstring

FieldTypeKeywordOrStringclj

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.
sourceraw docstring

IntGreaterThanOrEqualToZeroclj

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.
sourceraw docstring

IntGreaterThanZeroclj

Schema representing an integer than must also be greater than zero.

Schema representing an integer than must also be greater than zero.
sourceraw docstring

IntStringclj

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`.
sourceraw docstring

IntStringGreaterThanOrEqualToZeroclj

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`.
sourceraw docstring

IntStringGreaterThanZeroclj

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`.
sourceraw docstring

JSONStringclj

Schema for a string that is valid serialized JSON.

Schema for a string that is valid serialized JSON.
sourceraw docstring

KeywordOrStringclj

Schema for something that can be either a Keyword or a String.

Schema for something that can be either a `Keyword` or a `String`.
sourceraw docstring

Mapclj

Schema for a valid map.

Schema for a valid map.
sourceraw docstring

non-emptyclj

(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`).
sourceraw docstring

NonBlankStringclj

Schema for a string that cannot be blank.

Schema for a string that cannot be blank.
sourceraw docstring

NonNegativeIntclj

Schema representing an integer 0 or greater

Schema representing an integer 0 or greater
sourceraw docstring

PositiveNumclj

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.
sourceraw docstring

with-api-error-messageclj

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close