@samatawy/checks
    Preparing search index...

    Class FieldCheck

    Common interface implemented by all check classes.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    key: string | number
    data: any
    has_value: boolean
    out: IResult

    Methods

    • Runs a group of field-level checks where all returned checks must pass.

      All returned checks must pass for the composed result to stay valid.

      Parameters

      Returns Promise<FieldCheck>

      const checker = await ObjectCheck.for({ age: '37' }).check(root => [
      root.required('age').allOf(field => [
      field.number({ tolerant: true }).greaterThan(17)
      ])
      ]);
    • Evaluates alternative field branches and succeeds when at least one branch is valid.

      Each branch function is evaluated in isolation using cloned parent data. Valid branches are then replayed on the current checker so mutations behave the same way as normal non-branch checks.

      Parameters

      Returns Promise<FieldCheck>

      const checker = await ObjectCheck.for({ value: '37' }).check(root => [
      root.required('value').anyOf([
      field => [field.number({ tolerant: true }).greaterThan(10)],
      field => [field.string().minLength(5)]
      ])
      ]);
    • Evaluates alternative field branches and succeeds only when exactly one branch is valid.

      Each branch function is evaluated in isolation using cloned parent data. The single winning branch is then replayed on the current checker so mutations behave the same way as normal non-branch checks.

      Parameters

      Returns Promise<FieldCheck>

    • Parameters

      • Optionalcurrent: string | string[]
      • Optionalincoming: string | string[]

      Returns string | string[] | undefined