blacklist (not-in-array) validator for Yii 2
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
BlackListValidator.php
README.md
composer.json

README.md

Yii 2 blacklist validator

A Validator that will check if a model attribute is blacklisted.

Installation and usage

Installation

$ composer require chouaibi/yii2-notinarray-validator

or

Add the package to your composer.json file.

{
  "require": {
    "chouaibi/yii2-blacklist-validator" : "dev-master"
  }
}

then run

$ composer update

Usage


    use chouaibi\validators\BlackListValidator;

    public function rules() {
        return [
            [['attribute'], BlackListValidator::className(), 'array' => ['black','listed','values']],
        ];
    }

With custom message


    use chouaibi\validators\BlackListValidator;

    public function rules() {
        return [
            [['attribute'], BlackListValidator::className(), 'array' => ['black','listed','values'],'message' => 'The attribute value is reserved. Please check our reserved values ...'],
        ];
    }