Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

Functions

Variables

Const FILTERED

FILTERED: __type

Functions

filter

  • filter(object: object, filter: any, context?: any): Promise<object>
  • Filters an object graph according to the rules defined in a filter. Returns an object graph with the same structure as the original, minus any properties that were removed by the filter. Note that prototype chains are NOT preserved by this method -- the result will be a simple instance of Object. Cycles and shared object references within the input object will be preserved in the output (presuming that they pass the filter).

    Parameters

    • object: object

      The object graph to filter.

    • filter: any

      A value that determines which properties of the original object are kept in the result. A filter can take on one of the following values:

      1. A boolean value. If true, then the value will be retained, otherwise it will be discarded.
      2. An object. Each property defined on the filter is itself a filter that is applied to the equivalent property on the original object. Any properties that are not defined in the filter are automatically excluded from the original object.
      3. An instance of {@link validation.Validator}. The value will be checked against the validator's validate() method, and will be kept only if the validation is successful.
      4. A callback function. The function will be invoked with the value, and the result will be used to perform further filtering.

      For array properties, the filter value can be an object containing a single property named item. In this case, the value of the filter's item property will be used to filter each item in the array, using the same rules as above.

    • Optional context: any

      Arbitrary data that will be passed to validators and callbacks within the filter.

    Returns Promise<object>