server/api/validators/generic

Methods

(static) equals(value) → {function}

Source:

Returns a ValDSL validator that checks whether a value is strictly equal to a fixed value.

this.validate(
  this.json("/type"),
  this.equal("Point")
);
Parameters:
Name Type Description
value *

The expected value.

Returns:

A validator function.

Type
function

(static) isSetAndNotNull() → {function}

Source:

Returns a ValDSL condition that checks whether the current value is set and not null.

Used when doing partial updates with PATCH, when the next validations should be run only if the property is set and not null, otherwise the property should be cleared.

Returns:

A condition function.

Type
function

(static) properties(properties) → {function}

Source:

Returns a ValDSL validator that checks whether an object has exactly the expected properties.

this.validate(
  this.json("/geometry"),
  this.properties("type", "coordinates")
)
Parameters:
Name Type Description
properties Array.<string>

The expected properties.

Returns:

A validator function.

Type
function

(static) query(param) → {function}

Source:

Returns a ValDSL function that changes the validated value from an Express request object to one of its query parameters.

Parameters:
Name Type Description
param string

The name of the query parameter to validate.

Returns:

A validator function.

Type
function