{"id":14975479,"url":"https://github.com/kartik-v/yii2-validators","last_synced_at":"2025-10-27T14:30:19.450Z","repository":{"id":57004667,"uuid":"141667789","full_name":"kartik-v/yii2-validators","owner":"kartik-v","description":"Enhanced Yii2 model validator components / utilities for Yii2 Framework","archived":false,"fork":false,"pushed_at":"2020-04-02T17:24:23.000Z","size":50,"stargazers_count":20,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-01T05:51:12.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://demos.krajee.com/validators","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kartik-v.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-20T05:33:53.000Z","updated_at":"2023-12-28T19:55:55.000Z","dependencies_parsed_at":"2022-08-21T12:40:36.099Z","dependency_job_id":null,"html_url":"https://github.com/kartik-v/yii2-validators","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartik-v%2Fyii2-validators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartik-v%2Fyii2-validators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartik-v%2Fyii2-validators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kartik-v%2Fyii2-validators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kartik-v","download_url":"https://codeload.github.com/kartik-v/yii2-validators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508393,"owners_count":19484127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:52:05.978Z","updated_at":"2025-10-27T14:30:18.900Z","avatar_url":"https://github.com/kartik-v.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"yii2-validators\n===============\n\n[![Stable Version](https://poser.pugx.org/kartik-v/yii2-validators/v/stable)](https://packagist.org/packages/kartik-v/yii2-validators)\n[![Unstable Version](https://poser.pugx.org/kartik-v/yii2-validators/v/unstable)](https://packagist.org/packages/kartik-v/yii2-validators)\n[![License](https://poser.pugx.org/kartik-v/yii2-validators/license)](https://packagist.org/packages/kartik-v/yii2-validators)\n[![Total Downloads](https://poser.pugx.org/kartik-v/yii2-validators/downloads)](https://packagist.org/packages/kartik-v/yii2-validators)\n[![Monthly Downloads](https://poser.pugx.org/kartik-v/yii2-validators/d/monthly)](https://packagist.org/packages/kartik-v/yii2-validators)\n[![Daily Downloads](https://poser.pugx.org/kartik-v/yii2-validators/d/daily)](https://packagist.org/packages/kartik-v/yii2-validators)\n\nThis extension adds new model validator components for Yii2 frameworkor and/or enhances existing Yii2 model validators. \n\nThe `EmailValidator` extends the [yii\\validators\\EmailValidator](https://www.yiiframework.com/doc/api/2.0/yii-validators-emailvalidator)\ncomponent to support multiple email inputs for Yii2 framework. In addition this validator allows setting the `multiple` property and\nsetting the `min` and `max` number of email addresses allowed. This is useful for adding validation rules to your attributes\nin the model and also adds enhanced client validation support for ActiveForm inputs at runtime via Javascript.\n\nThe `PhoneValidator` extends the [yii\\validators\\Validator](https://www.yiiframework.com/doc/api/2.0/yii-validators-validator) component\nusing [libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php) based on Google's\n[libphonenumber](https://github.com/googlei18n/libphonenumber) library.\n\nThe `CardValidator` extends the [yii\\validators\\Validator](https://www.yiiframework.com/doc/api/2.0/yii-validators-validator) component.\nIt validates standard debit and credit card number inputs using Luhn's checksum validation. It also helps auto detect the card types and\nadditionally validating the card holder name, expiry date and CVV entered.\n\nThe `JsonValidator` extends the [yii\\validators\\Validator](https://www.yiiframework.com/doc/api/2.0/yii-validators-validator) component.\nIt validates JSON input in text area fields. The validator also helps to overwrite the JSON input as a pretty format via `prettify` setting.\nIt includes both server and client validations.\n\n## Demo\nYou can see detailed [documentation and demos](http://demos.krajee.com/validators) on usage of this extension.\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\n\u003e NOTE: Check the [composer.json](https://github.com/kartik-v/yii2-validators/blob/master/composer.json) for this extension's requirements and dependencies. Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json.\n\nEither run\n\n```\n$ php composer.phar require kartik-v/yii2-validators \"@dev\"\n```\n\nor add\n\n```\n\"kartik-v/yii2-validators\": \"@dev\"\n```\n\nto the ```require``` section of your `composer.json` file.\n\n## Usage\n\n### EmailValidator\n\nThis class extends the `yii\\validators\\EmailValidator` class to offer multiple email validation support. The `EmailValidator` class\ncan be easily used via the alias `k-email` in your model validation rules. For example in your model you can use this as shown below:\n\n```php\nuse yii\\db\\ActiveRecord;\n\nclass EmailModel extends ActiveRecord {\n    /**\n     * @return array the validation rules.\n     */\n    public function rules()\n    {\n        return [\n            [['to', 'cc', 'bcc'], 'k-email', 'allowName' =\u003e true, 'enableIDN' =\u003e true, 'max' =\u003e 5],\n        ];\n    }\n}\n```\n\nIn your view where you render the model inputs with ActiveForm - you may set `enableClientValidation` to control whether you need client side validation.\n\n```php\n// views/email/send.php\n\nuse yii\\widgets\\ActiveForm;\n\n$form = ActiveForm::begin(['enableClientValidation' =\u003e true]);\necho $form-\u003efield($model, 'to')-\u003etextInput();\necho $form-\u003efield($model, 'cc')-\u003etextInput();\necho $form-\u003efield($model, 'bcc')-\u003etextInput();\n// other fields\nActiveForm::end();\n```\n\n### PhoneValidator\n\nThis class extends the `yii\\validators\\Validator` class to validate phone numbers using\n[libphonenumber-for-php](https://github.com/giggsey/libphonenumber-for-php) based on Google's\n[libphonenumber](https://github.com/googlei18n/libphonenumber) library. The `PhoneValidator` class\ncan be easily used via the alias `k-phone` in your model validation rules. For example in your \nmodel you can use this as shown below:\n\n```php\nuse yii\\db\\ActiveRecord;\n\nclass ContactModel extends ActiveRecord {\n    /**\n     * @return array the validation rules.\n     */\n    public function rules()\n    {\n        return [\n            [['phone1'], 'k-phone', 'countryValue' =\u003e 'US'],\n            [['phone2'], 'k-phone', 'countryAttribute' =\u003e 'country', 'applyFormat' =\u003e false],\n        ];\n    }\n}\n```\n\n### CardValidator\n\nThe `CardValidator` extends the [yii\\validators\\Validator](https://www.yiiframework.com/doc/api/2.0/yii-validators-validator) component.\nIt validates standard debit and credit card number inputs using Luhn's checksum validation. It also helps auto detect the card types and\nadditionally validating the card holder name, expiry date and CVV entered. The `CardValidator` class\ncan be easily used via the alias `k-card` in your model validation rules. For example in your \nmodel you can use this as shown below:\n\n```php\nuse yii\\db\\ActiveRecord;\n\nclass PaymentModel extends ActiveRecord {\n    /**\n     * @return array the validation rules.\n     */\n    public function rules()\n    {\n        return [\n            [\n                ['card_number'], \n                'k-card', \n                'typeAttribute' =\u003e 'card_type', \n                'holderAttribute' =\u003e 'holderName',\n                'expiryYearAttribute' =\u003e 'expiryYear',\n                'expiryMonthAttribute' =\u003e 'expiryMonth',\n                'cvvAttribute' =\u003e 'cvv',\n            ],\n        ];\n    }\n}\n```\n\n### JsonValidator\n\nThe `JsonValidator` extends the [yii\\validators\\Validator](https://www.yiiframework.com/doc/api/2.0/yii-validators-validator) component.\nIt validates JSON input in text area fields. The validator also helps to overwrite the JSON input as a pretty format via `prettify` setting.\nIt includes both server and client validations. The `JsonValidator` class can be easily used via the alias `k-json` in your model validation \nrules. For example in your model you can use this as shown below:\n\n```php\nuse yii\\db\\ActiveRecord;\n\nclass ProductModel extends ActiveRecord {\n    /**\n     * @return array the validation rules.\n     */\n    public function rules()\n    {\n        return [\n            [\n                ['products_list_json'], \n                'k-json', \n                'prettify' =\u003e true, // set this to false if you do not wish to prettify the json input\n            ],\n        ];\n    }\n}\n```\n\n## License\n\n**yii2-validators** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkartik-v%2Fyii2-validators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkartik-v%2Fyii2-validators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkartik-v%2Fyii2-validators/lists"}