UserFrosting API

ClientSideValidationAdapter

ClientSideValidationAdapter Class.

Loads validation rules from a schema and generates client-side rules compatible with a particular client-side (usually Javascript) plugin.

Tags
author

Alex Weissman (https://alexanderweissman.com)

Table of Contents

$schema RequestSchemaInterface
$translator Translator
__construct() Create a new client-side validator. mixed
setSchema() Set the schema for this validator. mixed
setTranslator() Set the translator for this validator, as a valid MessageTranslator object. mixed
rules() Generate and return the validation rules for this specific validation adapter. mixed

Properties

Methods

setTranslator()

Set the translator for this validator, as a valid MessageTranslator 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

rules()

Generate and return the validation rules for this specific validation adapter.

public abstract rules( [ $format : string = 'json' ] [, $stringEncode : bool = true ] ) : mixed

This method returns a collection of rules, in the format required by the specified plugin.

Parameters
$format : string = 'json'

The format in which to return the rules. For example, "json" or "html5".

$stringEncode : bool = true

In the case of JSON rules, specify whether or not to encode the result as a serialized JSON string.

Return values
mixed

The validation rule collection.

Search results