Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "wed/object-check"

Index

Type aliases

CheckResults

CheckResults: Partial<_CheckResults>

Functions

_check

_required

  • _required(template: Template, name: string): boolean
  • Checks whether a field is required.

    Parameters

    • template: Template

      The template to check.

    • name: string

      The name of the field.

    Returns boolean

    Whether the field is required or not.

assertExtensively

  • assertExtensively(template: Template, toCheck: __type): void
  • Check whether the object fits the template, and throw an error that reports all issues.

    throws

    {Error} If there is any error.

    Parameters

    • template: Template

      The template to use for the check.

    • toCheck: __type

      The object to check

    Returns void

assertSummarily

  • assertSummarily(template: Template, toCheck: __type): void
  • Check whether the object fits the template, and throw at the first sign of trouble. The thrown object contains information about the first error encountered.

    throws

    {Error} If there is any error.

    Parameters

    • template: Template

      The template to use for the check.

    • toCheck: __type

      The object to check

    Returns void

check

  • Checks whether an object conforms to a template. The template must be an object which specifies the known fields and which among them are required. A field is known if it appears in the template. A field is considered required if:

    • it is an object which has any field which is required, or

    • it is not an object but evaluates to a true value.

    A required field which does not appear in the object being checked will appear in the missing field in the returned value.

    A field which appears on the object being checked but which is not known will appear in the extra field in the returned value.

    The fields mentioned above exist only if there is something to report. The names returned in the lists are fully qualified names.

    For instance, given this template:

    {
        foo: false,
        bar: {
            baz: true,
            bin: false,
        },
        bip: {
            baz: false,
            bin: false,
        }
    }
    

    The names "foo", "bar", "bar.baz", "bar.bin", "bip", "bip.baz", bip.bin" are known. The names "bar" and "bar.baz" are required. The name "bar" is required because "bar.baz" is required. The other names correspond to objects whose fields are not required or are non-object values that evaluate to false.

    Parameters

    • template: Template

      The template to use for the check.

    • toCheck: __type

      The object to check

    Returns CheckResults

    The results.

Generated using TypeDoc