Download the PHP package codeonyii/yii2-at-least-validator without Composer
On this page you can find all versions of the php package codeonyii/yii2-at-least-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codeonyii/yii2-at-least-validator
More information about codeonyii/yii2-at-least-validator
Files in codeonyii/yii2-at-least-validator
Package yii2-at-least-validator
Short Description Validates at least one (or more) attributes.
License Apache-2.0
Homepage https://github.com/code-on-yii/yii2-at-least-validator
Informations about the package yii2-at-least-validator
Yii 2 - AtLeastValidator
Sometimes, in a set of fields, you need to make at least one of them (sometimes two, or more) be filled. For example, phone OR e-mail, (facebook OR linkedin) OR (linkedin OR instagram) and so on. You can do it using required validator with a bunch of conditional rules. Or you can use AtLeastValidator.
Installation
Use composer:
In your Model, import the validator:
Examples
In the following example, the phone and email attributes will
be verified. If none of them are filled phone will receive an error.
Please, note that in param is always mandatory.
Here, facebook, linkedin and instagram attributes will
be verified. If at least 2 (note the min param) of them are not filled,
facebook and instagram will receive an error:
Showing errors in summary
If you want to show errors in a summary instead in the own attributes, you can do this:
Note that summary will not work for client-side validation. If you want to use it, you should disable the client-side validation for your fields or for your entire form.
Changelog
Please, access Releases to see versions with a some description.
