UserFrosting API

ServerSideValidatorInterface

ServerSideValidator Interface.

Loads validation rules from a schema and validates a target array of data.

Tags
author

Alexander Weissman (https://alexanderweissman.com)

Table of Contents

setSchema() Set the schema for this validator, as a valid RequestSchemaInterface object. mixed
setTranslator() Set the translator for this validator, as a valid Translator object. mixed
validate() Validate the specified data against the schema rules. bool
data() Get array of fields and data. array
errors() Get array of error messages. array|bool

Methods

setTranslator()

Set the translator for this validator, as a valid Translator object.

public setTranslator( $translator : Translator ) : mixed
Parameters
$translator : Translator

A Translator to be used to translate message ids found in the schema.

Return values
mixed

validate()

Validate the specified data against the schema rules.

public validate( $data : array ) : bool
Parameters
$data : array

An array of data, mapping field names to field values.

Return values
bool

True if the data was successfully validated, false otherwise.

Search results