FieldReader

Universal functionality for picking input values from Incoming Body. Can not be instantiated directly, but should be used by implementations specific to the type of input.

What it does

When an implementation of FieldReader (such as BodyReader or QueryReader) is hit, input data will be acquired from the appropriate source, depending on the implementation.

The acquired data will be loaded into a validator.

When input gets validated successfully, an Interaction with all validated input values will be handed to the next service.

If validation fails, an alternative branch will be invoked. Depending on configuration, additional branches may be invoked depending on where errors occurred.

Implementations

GetFieldReader Useful when control originates from an HTTP server; will use URL query string as input
PostFieldReader Useful when control originates from an HTTP-server; will use POST-body as input
JsonFieldReader Uses a modified CLON-parser to read JSON; will use JSON as input

How it works

Check out the examples at QueryReader or BodyReader.

Settings

escapehtml true/false input that isn't safe for html should be converted to html &entities;
showformbefore true/false the form-branch should be executed before the successful-branch is executed
showformafter true/false the form-branch should be executed after the successful-brnahc is executed
maperrors true/false error-message branches should output their message into form context instead of the nearest Outgoing Interaction
field_[name of field] "string" regular expression as a validation rule for the field with this name
casesensitive true/false validation rules are case sensitive
default_[name of branch] "string" default value when field was left unfilled
allowfallback ["string", "array"] field names that may be acquired from pre-existing context when missing from FieldReader datasource (this data source would be the HTTP POST body for a PostFieldReader, for example)

Branches

_branch-name trigger interaction
successful when input was validated successfully VerificationInteraction
form when showformbefore/showformafter was set or input was not validated successfully VerificationInteraction
[name of field]_failure error handler will be invoked when field with [name of field] is faulty. -
failhandle possibly a nice insult. connect to module containing branches with error handlers (can be Templates with simple messages). be mindful to match names with field names. -