Validator

Validator

Validation helper class.

Constructor

new Validator()

Source:

Methods

create() → {ValidatorFunction}

Create a validation function for schema schema.

Source:
Returns:

Validation function

Type
ValidatorFunction

loadSchemasFromDirectory(dirPath)

Load additional schemas from the provided directory.

The schemas must be individual JSON files with the .json extension.

Parameters:
Name Type Description
dirPath String

Absolute path to the schemas

Source:

loadSharedSchemas()

Load the schemas shipped with five-bells-shared.

Source:

validateBody(ctx, schema) → {Promise.<Mixed>}

Parse the request body JSON and optionally validate it against a schema.

Parameters:
Name Type Description
ctx Object

Koa context.

schema String

Name of JSON schema.

Source:
Returns:

Parsed JSON body

Type
Promise.<Mixed>

validateUriParameter(paramId, paramValue, schema) → {void}

Validate path parameter.

Parameters:
Name Type Description
paramId String

Name of URL parameter.

paramValue String

Value of URL parameter.

schema String

Name of JSON schema.

Source:
Returns:
Type
void