Liking cljdoc? Tell your friends :D

dev.jaide.valhalla.core


assertcljs

(assert pred?)
(assert pred? opts)

Validates if a value satisfies a predicate function.

Arguments:

  • pred? - A predicate function that returns true for valid values

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the original value if the predicate returns true.

Validates if a value satisfies a predicate function.

Arguments:
- pred? - A predicate function that returns true for valid values

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the original value if the predicate returns true.
raw docstring

assert-validcljs

(assert-valid validator input & {:keys [message]})

Validates input and throws an error if invalid.

Options:

  • :message - Custom error message function or string

Returns the validation result if valid

Validates input and throws an error if invalid.

Options:
- :message - Custom error message function or string

Returns the validation result if valid
raw docstring

booleancljs

(boolean)
(boolean opts)

Validates if a value is a boolean.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.

Validates if a value is a boolean.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
raw docstring

chaincljs

(chain & validators)

Creates a validator that applies multiple validators in sequence.

Arguments:

  • validators - A sequence of validator functions to apply in order

Returns a validator function that accepts a context and returns a result. Each validator is applied to the result of the previous validator. If any validator fails, the chain stops and returns the error.

Creates a validator that applies multiple validators in sequence.

Arguments:
- validators - A sequence of validator functions to apply in order

Returns a validator function that accepts a context and returns a result.
Each validator is applied to the result of the previous validator.
If any validator fails, the chain stops and returns the error.
raw docstring

datecljs

(date & [opts])

Validates if a value is a valid JavaScript Date object.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the original Date object if valid.

Validates if a value is a valid JavaScript Date object.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the original Date object if valid.
raw docstring

date->numbercljs

(date->number)
(date->number opts)

Converts a JavaScript Date object to a timestamp number.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the timestamp (milliseconds since epoch) of the date.

Converts a JavaScript Date object to a timestamp number.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the timestamp (milliseconds since epoch) of the date.
raw docstring

date->stringcljs

(date->string)
(date->string opts)

Converts a JavaScript Date object to an ISO string.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the ISO string representation of the date.

Converts a JavaScript Date object to an ISO string.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the ISO string representation of the date.
raw docstring

defaultcljs

(default validator default-value-or-fn)

Creates a validator that provides a default value for nil inputs.

Arguments:

  • validator - A validator function to apply to non-nil values
  • default-value-or-fn - A value or function to use as default for nil values

Returns a validator function that accepts a context and returns a result. If the input is nil, returns the default value or the result of calling the default function with the context.

Creates a validator that provides a default value for nil inputs.

Arguments:
- validator - A validator function to apply to non-nil values
- default-value-or-fn - A value or function to use as default for nil values

Returns a validator function that accepts a context and returns a result.
If the input is nil, returns the default value or the result of calling
the default function with the context.
raw docstring

enumcljs

(enum kws)
(enum kws opts)

Validates if a value is one of a set of keywords.

Arguments:

  • kws - A collection of keywords representing valid enum values

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the original keyword if it's one of the specified enum values.

Validates if a value is one of a set of keywords.

Arguments:
- kws - A collection of keywords representing valid enum values

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the original keyword if it's one of the specified enum values.
raw docstring

errorcljs

(error message)

Creates an error result with the given message.

Returns a vector with :v/error status and the error message.

Creates an error result with the given message.

Returns a vector with :v/error status and the error message.
raw docstring

errorscljs

(errors errors)

Creates a result containing multiple errors.

Returns a vector with :v/errors status and a collection of error messages.

Creates a result containing multiple errors.

Returns a vector with :v/errors status and a collection of error messages.
raw docstring

errors->stringcljs

(errors->string errors)

Formats a list of error hash-maps into a line-separated string

Arguments:

  • errors - Sequence of error hash-maps with :path vectors and :message str

Returns a string of all error messages

Formats a list of error hash-maps into a line-separated string

Arguments:
- errors - Sequence of error hash-maps with :path vectors and :message str

Returns a string of all error messages
raw docstring

failcljs

(fail & {:keys [input errors]})

Creates a failed validation result.

Returns a map with :v/fail status, the input value, and error messages.

Creates a failed validation result.

Returns a map with :v/fail status, the input value, and error messages.
raw docstring

hash-mapcljs

(hash-map value-validator)
(hash-map key-validator value-validator)
(hash-map key-validator value-validator opts)

Validates if a value is a hash-map with a key and value type.

Arguments:

  • key - A key validator function
  • value - A value validator function

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a hash-map of unknown size.

Validates if a value is a hash-map with a key and value type.

Arguments:
- key - A key validator function
- value - A value validator function

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a hash-map of unknown size.
raw docstring

instancecljs

(instance class-fn)
(instance class-fn opts)

Validates if a value is an instance of a specific class.

Arguments:

  • class-fn - A JavaScript constructor function or class

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the original value if it's an instance of the specified class.

Validates if a value is an instance of a specific class.

Arguments:
- class-fn - A JavaScript constructor function or class

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the original value if it's an instance of the specified class.
raw docstring

keywordcljs

(keyword)
(keyword opts)

Validates if a value is a keyword.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.

Validates if a value is a keyword.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
raw docstring

lazycljs

(lazy validator-fn & [opts])

Creates a validator that lazily evaluates a validator function.

Arguments:

  • validator-fn - A function that returns a validator function

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result. The validator-fn is called to get the actual validator only when needed, which allows for recursive validator definitions.

Creates a validator that lazily evaluates a validator function.

Arguments:
- validator-fn - A function that returns a validator function

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
The validator-fn is called to get the actual validator only when needed,
which allows for recursive validator definitions.
raw docstring

listcljs

(list validator & [opts])

Validates if a value is a list and validates each element.

Arguments:

  • validator - A validator function to apply to each element

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a sequence of validated elements if successful.

Validates if a value is a list and validates each element.

Arguments:
- validator - A validator function to apply to each element

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a sequence of validated elements if successful.
raw docstring

list-tuplecljs

(list-tuple validators & [opts])

Validates if a value is a list with specific validators for each position.

Arguments:

  • validators - A sequence of validator functions, one for each position

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a sequence of validated elements if successful. The input list must have the same length as the validators sequence.

Validates if a value is a list with specific validators for each position.

Arguments:
- validators - A sequence of validator functions, one for each position

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a sequence of validated elements if successful. The input list must have
the same length as the validators sequence.
raw docstring

literalcljs

(literal expected)
(literal expected opts)

Validates if a value equals an expected literal value.

Arguments:

  • expected - The exact value to match against

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the original value if it equals the expected value.

Validates if a value equals an expected literal value.

Arguments:
- expected - The exact value to match against

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the original value if it equals the expected value.
raw docstring

nil-valuecljs

(nil-value)
(nil-value opts)

Validates if a value is nil.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.

Validates if a value is nil.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
raw docstring

nilablecljs

(nilable validator)

Creates a validator that allows nil values or validates non-nil values.

Arguments:

  • validator - A validator function to apply to non-nil values

Returns a validator function that accepts a context and returns a result with nil for nil values or the result of applying the validator to non-nil values.

Creates a validator that allows nil values or validates non-nil values.

Arguments:
- validator - A validator function to apply to non-nil values

Returns a validator function that accepts a context and returns a result
with nil for nil values or the result of applying the validator to non-nil values.
raw docstring

numbercljs

(number)
(number opts)

Validates if a value is a number.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.

Validates if a value is a number.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
raw docstring

number->datecljs

(number->date)
(number->date opts)

Converts a number (timestamp) to a JavaScript Date object.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a Date object if the number represents a valid timestamp.

Converts a number (timestamp) to a JavaScript Date object.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a Date object if the number represents a valid timestamp.
raw docstring

numericcljs

(numeric)
(numeric opts)

Validates if a value can be parsed as a number.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result. The original string value is returned if valid.

Validates if a value can be parsed as a number.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
The original string value is returned if valid.
raw docstring

okcljs

(ok value)

Creates a success result with the given value.

Returns a vector with :v/ok status and the value.

Creates a success result with the given value.

Returns a vector with :v/ok status and the value.
raw docstring

ok?cljs

(ok? [status _value])

Checks if a result is successful.

Returns true if the result has :v/ok status, false otherwise.

Checks if a result is successful.

Returns true if the result has :v/ok status, false otherwise.
raw docstring

passcljs

(pass & {:keys [input output]})

Creates a successful validation result.

Returns a map with :v/pass status and the input and output values.

Creates a successful validation result.

Returns a map with :v/pass status and the input and output values.
raw docstring

recordcljs

(record validators-map & [opts])

Validates if a value is a hash-map and validates specific keys.

Arguments:

  • validators-map - A hash-map of keys to validator functions

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a map of validated key-value pairs if successful.

Validates if a value is a hash-map and validates specific keys.

Arguments:
- validators-map - A hash-map of keys to validator functions

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a map of validated key-value pairs if successful.
raw docstring

regexcljs

(regex regex-str)
(regex regex-str opts)

Validates if a string matches a regular expression pattern.

Arguments:

  • regex-str - The regular expression pattern as a string

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the original string if it matches the pattern.

Validates if a string matches a regular expression pattern.

Arguments:
- regex-str - The regular expression pattern as a string

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the original string if it matches the pattern.
raw docstring

result-casecljs

(result-case [status val-or-msg]
             &
             {:keys [ok err errs] :or {ok identity err identity errs identity}})

Pattern matches on a validation result and applies the appropriate handler function.

Takes a result vector [status value] and handler functions for each possible status. Returns the result of applying the matching handler to the value.

Pattern matches on a validation result and applies the appropriate handler function.

Takes a result vector [status value] and handler functions for each possible status.
Returns the result of applying the matching handler to the value.
raw docstring

setcljs

(set validator & [opts])

Validates if a value is a set and validates each element.

Arguments:

  • validator - A validator function to apply to each element

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a set of validated elements if successful.

Validates if a value is a set and validates each element.

Arguments:
- validator - A validator function to apply to each element

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a set of validated elements if successful.
raw docstring

stringcljs

(string)
(string opts)

Validates if a value is a string.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.

Validates if a value is a string.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
raw docstring

string->booleancljs

(string->boolean)
(string->boolean opts)

Converts a string ('true' or 'false') to a boolean.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the parsed boolean value if successful.

Converts a string ('true' or 'false') to a boolean.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the parsed boolean value if successful.
raw docstring

string->datecljs

(string->date)
(string->date opts)

Converts a string to a JavaScript Date object.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a Date object if the string can be parsed as a valid date.

Converts a string to a JavaScript Date object.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a Date object if the string can be parsed as a valid date.
raw docstring

string->keywordcljs

(string->keyword)
(string->keyword opts)

Converts a string to a keyword.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the converted keyword if successful. The string must match the pattern for valid keywords (optionally starting with ':' followed by valid characters).

Converts a string to a keyword.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the converted keyword if successful. The string must match the pattern
for valid keywords (optionally starting with ':' followed by valid characters).
raw docstring

string->numbercljs

(string->number)
(string->number opts)

Converts a string to a number.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the parsed number value if successful.

Converts a string to a number.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the parsed number value if successful.
raw docstring

string->symbolcljs

(string->symbol)
(string->symbol opts)

Converts a string to a symbol.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the converted symbol if successful. The string must match the pattern for valid symbols (starting with a letter followed by valid characters).

Converts a string to a symbol.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the converted symbol if successful. The string must match the pattern
for valid symbols (starting with a letter followed by valid characters).
raw docstring

symbolcljs

(symbol)
(symbol opts)

Validates if a value is a symbol.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.

Validates if a value is a symbol.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result.
raw docstring

unioncljs

(union & validators)

Creates a validator that tries multiple validators and succeeds if any one succeeds.

Arguments:

  • validators - A sequence of validator functions to try

Returns a validator function that accepts a context and returns a result. Each validator is tried in order until one succeeds. If all validators fail, returns the errors from the last validator.

Creates a validator that tries multiple validators and succeeds if any one succeeds.

Arguments:
- validators - A sequence of validator functions to try

Returns a validator function that accepts a context and returns a result.
Each validator is tried in order until one succeeds. If all validators fail,
returns the errors from the last validator.
raw docstring

uuidcljs

(uuid)
(uuid opts)

Validates if a string is a valid UUID.

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with the original UUID string if valid.

Validates if a string is a valid UUID.

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with the original UUID string if valid.
raw docstring

valid?cljs

(valid? result)

Checks if a validation result is successful.

Returns true if the result has :v/pass status, false otherwise.

Checks if a validation result is successful.

Returns true if the result has :v/pass status, false otherwise.
raw docstring

validatecljs

(validate validator-fn input & [opts])

Validates an input value using the provided validator function.

Creates a validation context with the input, applies the validator, and returns a validation result map (pass or fail).

Validates an input value using the provided validator function.

Creates a validation context with the input, applies the validator,
and returns a validation result map (pass or fail).
raw docstring

vectorcljs

(vector validator & [opts])

Applies a validator to every item in a vector

Arguments:

  • validator - A validator function to apply to each element

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a vector of validated elements if successful.

Applies a validator to every item in a vector

Arguments:
- validator - A validator function to apply to each element

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a vector of validated elements if successful.
raw docstring

vector-tuplecljs

(vector-tuple validators & [opts])

Validates if a value is a vector with specific validators for each position.

Arguments:

  • validators - A vector of validator functions, one for each position

Options:

  • :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result with a vector of validated elements if successful. The input vector must have the same length as the validators vector.

Validates if a value is a vector with specific validators for each position.

Arguments:
- validators - A vector of validator functions, one for each position

Options:
- :message - Custom error message function or string

Returns a validator function that accepts a context and returns a result
with a vector of validated elements if successful. The input vector must have
the same length as the validators vector.
raw docstring

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

× close