FormsUnit

flitter-forms/FormsUnit~ FormsUnit

Unit to register functionality provided by flitter-forms.

Constructor

new FormsUnit(directoryopt)

Source:

Instantiates the class. Resolves the path to the schemata folder.

Parameters:
Name Type Attributes Default Description
directory string <optional>
'./app/validators'

path to the directory where validator definition schemata are located.

Extends

Methods

(async) cleanup(app) → {Promise.<void>}

Source:
Inherited From:

Cleans up the unit's resources before Flitter closes.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

Returns:
Type
Promise.<void>

(async) deploy() → {Promise.<void>}

Source:

Deploy the sample files provided by this unit. Creates the "app/validators" directory and an example validator schema.

Returns:
Type
Promise.<void>

directories() → {Object}

Source:
Overrides:

Get the directories managed by this unit.

Returns:
Type
Object

(async) go(app, context) → {Promise.<void>}

Source:
Overrides:

Loads the unit. Imports the validators in module:flitter-forms/FormsUnit~FormsUnit#directory and registers them by name. Also binds validators, schemata and helper functions to the appropriate contexts.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

context module:libflitter/Context~Context

the Unit's context

Returns:
Type
Promise.<void>

init(validator, request)

Source:

Initialize a validator by creating a new error session with the validator's name in the request's session data.

Parameters:
Name Type Description
validator module:flitter-forms/Validator~Validator

the Validator instance to be initialized

request Express/Request

the Express request

name() → {string}

Source:
Overrides:

Get the name of this unit.

Returns:

"forms"

Type
string

templates() → {Object}

Source:

Get the templates provided by this unit.

Returns:
Type
Object

validator(name) → {module:flitter-forms/Validator~Validator}

Source:

Get a registered Validator instance by name. Only works when bound to the FlitterApp.

Parameters:
Name Type Description
name string

name of the validator to retrieve. should be a Flitter canonical name.

Returns:
Type
module:flitter-forms/Validator~Validator