@samatawy/checks
    Preparing search index...

    Class ArrayItemCheck

    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 item-level checks where all returned checks must pass.

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

      Parameters

      Returns Promise<ArrayItemCheck>

      const checker = await ObjectCheck.for({ values: ['Ada'] }).check(root => [
      root.required('values').array().checkEach(item => [
      item.allOf(entry => [entry.string().minLength(2)])
      ])
      ]);
    • Evaluates alternative item branches and succeeds when at least one branch is valid.

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

      Parameters

      Returns Promise<ArrayItemCheck>

      const checker = await ObjectCheck.for({ values: ['  Ada  '] }).check(root => [
      root.required('values').array().checkEach(item => [
      item.anyOf([
      entry => [entry.string().trim().minLength(2)],
      entry => [entry.number().greaterThan(10)]
      ])
      ])
      ]);
    • Evaluates alternative item branches and succeeds only when exactly one branch is valid.

      Each branch function is evaluated in isolation using cloned parent array 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<ArrayItemCheck>

    • Parameters

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

      Returns string | string[] | undefined