Liking cljdoc? Tell your friends :D

dev.jaide.valhalla.core


->cljs

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

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

date->numbercljs

(date->number)
(date->number {:keys [accept-numbers] :as opts})

Converts a JavaScript Date object to a timestamp number.

Options:

  • :message - Custom error message function or string
  • :accept-numbers - Boolean to accept pre-transformed numbers

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
- :accept-numbers - Boolean to accept pre-transformed numbers

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

date->stringcljs

(date->string)
(date->string {:keys [accept-strings] :as opts})

Converts a JavaScript Date object to an ISO string.

Options:

  • :message - Custom error message function or string
  • :accept-strings - Boolean to accept pre-transformed, pattern-tested stings.

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
- :accept-strings - Boolean to accept pre-transformed, pattern-tested stings.

Returns a validator function that accepts a context and returns a result
with the ISO string representation of the date.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

number->datecljs

(number->date)
(number->date {:keys [accept-dates] :as opts})

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

Options:

  • :message - Custom error message function or string
  • :accept-dates - Boolean to accept pre-transformed, valid dates

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
- :accept-dates - Boolean to accept pre-transformed, valid dates

Returns a validator function that accepts a context and returns a result
with a Date object if the number represents a valid timestamp.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

parsecljs

(parse validator input & {:keys [_message] :as opts})

Validates input and throws an error if invalid.

Options:

  • :message - Custom error message function or string

Returns the parsed result if valid

Validates input and throws an error if invalid.

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

Returns the parsed result if valid
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

result-casecljs

(result-case [status val-or-msg]
             &
             {:keys [ok err errs ctx]
              :or {ok identity err identity errs identity ctx 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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

string->booleancljs

(string->boolean)
(string->boolean {:keys [accept-booleans] :as opts})

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

Options:

  • :message - Custom error message function or string
  • :accept-booleans - Boolean to accept pre-transformed values

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
- :accept-booleans - Boolean to accept pre-transformed values

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

string->datecljs

(string->date)
(string->date {:keys [accept-dates] :as opts})

Converts a string to a JavaScript Date object.

Options:

  • :message - Custom error message function or string
  • :accept-dates - Boolean to accept pre-transformed, valid dates

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
- :accept-dates - Boolean to accept pre-transformed, valid dates

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

string->keywordcljs

(string->keyword)
(string->keyword {:keys [accept-keywords] :as opts})

Converts a string to a keyword.

Options:

  • :message - Custom error message function or string
  • :accept-keywords - Boolean to accept pre-transformed keywords

Returns a validator function that accepts a context and returns a result with the converted keyword if successful.

Converts a string to a keyword.

Options:
- :message - Custom error message function or string
- :accept-keywords - Boolean to accept pre-transformed keywords

Returns a validator function that accepts a context and returns a result
with the converted keyword if successful.
sourceraw docstring

string->numbercljs

(string->number)
(string->number {:keys [accept-numbers] :as opts})

Converts a string to a number.

Options:

  • :message - Custom error message function or string
  • :accept-numbers - Boolean to accept pre-transformed numbers

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
- :accept-numbers - Boolean to accept pre-transformed numbers

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

string->symbolcljs

(string->symbol)
(string->symbol {:keys [accept-symbols] :as opts})

Converts a string to a symbol.

Options:

  • :message - Custom error message function or string
  • :accept-symbols - Boolean to accept pre-transformed symbols

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
- :accept-symbols - Boolean to accept pre-transformed symbols

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

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

× close