Class defaultAbstract

The default export of the jointz library that exposes static methods for constructing validators.

Hierarchy

  • default

Constructors

Methods

  • Return a validator that always succeeds but does not limit the type.

    Returns default

  • Return a validator that checks the value is an array, optionally validating each item in the array

    Type Parameters

    • TItem

    Parameters

    • Optional itemValidator: Validator<TItem>

      validator for the individual array items

    Returns default<TItem>

  • Return a validator that checks that the value is either true or false. This is an alias for constructing a constant validator.

    Returns Validator<boolean>

  • Return a constant validator that checks that the value is one of a set of given values.

    Type Parameters

    • T extends AllowedValueTypes[]

    Parameters

    • Rest ...allowedValues: T

      the values that are considered valid. can be numbers, strings, booleans, null, or undefined

    Returns default<T>

  • Return a validator that checks the string contains JSON that when parsed matches some validation

    Type Parameters

    • T

    Parameters

    • parsed: Validator<T>

      the validation to be applied to the parsed JSON

    Returns Validator<string>

  • Create a validator that checks that the value is a number. Call additional methods to add constraints to the number.

    Returns default

  • Create a validator that checks that the value is an object with a given shape.

    By default the object is not allowed to have keys other than what are specified. Call allowUnknownKeys(true) on the returned object validator to allow the object to have keys that are not specified which are not validated.

    Type Parameters

    • TKeys extends Keys

    Parameters

    • keys: TKeys

      validation to apply to each key in the object

    Returns default<TKeys, never, false>

  • Combine a list of validators to produce a new validator that passes if any of the given validators pass

    Type Parameters

    Parameters

    • Rest ...validators: T | [T]

      validators to combine into an OR expression validator

    Returns default<Infer<T>[number]>

  • Create a validator that checks the value is a string.

    Returns default

  • Create a validator that checks that the given value is a tuple of values that match the given validators.

    Type Parameters

    Parameters

    • Rest ...validators: T | [T]

      list of validators that the items in the tuple should match in order

    Returns default<Infer<T>>

Generated using TypeDoc