ClientValidatorScriptInterface
API reference › yii › validators › client › ClientValidatorScriptInterface
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.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
getClientOptions() abstract | Returns client-side validation options for the specified validator, model, and attribute. | ClientValidatorScriptInterface |
register() abstract | Registers the client-side validation script for the specified validator, model, and attribute in the view. | ClientValidatorScriptInterface |
Method details
Section titled “Method details”getClientOptions()
Section titled “getClientOptions() ”abstract public function getClientOptions(yii\validators\client\T $validator, yii\base\Model $model, string $attribute): array<string, mixed>Returns client-side validation options for the specified validator, model, and attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$validator | yii\ | The validator instance. |
$model | yii\ | The data model being validated. |
$attribute | string | The attribute name being validated. |
Returns
array<string, mixed>: Client-side validation options.
register()
Section titled “register() ”abstract public function register(yii\validators\client\T $validator, yii\base\Model $model, string $attribute, yii\web\View $view): string|nullRegisters the client-side validation script for the specified validator, model, and attribute in the view.
Parameters
| Parameter | Type | Description |
|---|---|---|
$validator | yii\ | The validator instance. |
$model | yii\ | The data model being validated. |
$attribute | string | The attribute name being validated. |
$view | yii\ | The view instance where the script will be registered. |
Returns
string|null: The client-side validation script, or null if not supported.