Options
All
  • Public
  • Public/Protected
  • All
Menu

Predefined valiation rules

Index

Predefined Rules

Const type

  • Valid if a type of value is that specified by param.

    Parameters

    • param: Json

      null|boolean|boolean?|integer|integer?|number|number?|string|object|object?|array|array?

    • value: Json

      value to validate

    • lookup: Lookup
    • rules: Rules

    Returns true | MgError

Const $enum

Const $const

Const notEmpty

Const required

  • Valid if value of Object has all properties specifed by param. If value is not an Object, then valid.

    Parameters

    Returns true | MgError

Const switchRequired

  • Valid if value of Object is an instance of a tagged union specified by param

    example
    param = {
    tagProperty: "tag",
    types: {
    leafOf: ["value"],
    nodeOf: ["left", "right"]
    }
    }
    switchRequired of `{tag:"leafOf", value:1}` evaludates valid.
    switchRequired of `{tag:"nodeOf", left:otherNode}` evaluates invalid since `right` property is missing.
    remark

    We can use tagged unions by using the switchRequired rule.
    But notice, even if the property sets are different, if the property names are the same, the schema will be the same.

    Parameters

    Returns true | MgError

Const same

Const $if

  • Valid if either of:

    • {target} conforms the rules of {match}, and value conforms the rules of {then}.
    • {target} doesn't conform the rules of {match}, and value conforms the rules of {else}. Where param is an array of:
    • {target} -- path to the target value
    • {match} -- rules for target
    • {then} -- rules of then clause
    • {else} -- rules of else clause

    Parameters

    Returns true | MgError

Const multipleOf

Const maximum

Const exclusiveMaximum

Const minimum

Const exclusiveMinimum

Const maxLength

Const minLength

Const pattern

Const maxItems

Const minItems

Generated using TypeDoc