0

Interface yii\validators\client\ClientValidatorScriptInterface

Available since version22.0
Source Code https://github.com/yiisoft/yii2/blob/master/framework/validators/client/ClientValidatorScriptInterface.php

Defines the contract for client-side validator script generation.

Classes implementing this interface provide methods for retrieving client-side validation options and registering the corresponding JavaScript code for a given validator, model, and attribute.

Public Methods

Hide inherited methods

Method Description Defined By
getClientOptions() Returns client-side validation options for the specified validator, model, and attribute. yii\validators\client\ClientValidatorScriptInterface
register() Registers the client-side validation script for the specified validator, model, and attribute in the view. yii\validators\client\ClientValidatorScriptInterface

Method Details

Hide inherited methods

getClientOptions() public abstract method

Returns client-side validation options for the specified validator, model, and attribute.

public abstract array getClientOptions ( \yii\validators\client\T $validator, yii\base\Model $model, string $attribute )
$validator \yii\validators\client\T

The validator instance.

$model yii\base\Model

The data model being validated.

$attribute string

The attribute name being validated.

return array

Client-side validation options.

                public function getClientOptions(Validator $validator, Model $model, string $attribute): array;

            
register() public abstract method

Registers the client-side validation script for the specified validator, model, and attribute in the view.

public abstract string|null register ( \yii\validators\client\T $validator, yii\base\Model $model, string $attribute, yii\web\View $view )
$validator \yii\validators\client\T

The validator instance.

$model yii\base\Model

The data model being validated.

$attribute string

The attribute name being validated.

$view yii\web\View

The view instance where the script will be registered.

return string|null

The client-side validation script, or null if not supported.

                public function register(Validator $validator, Model $model, string $attribute, View $view): string|null;