Skip to content

blacklist (not-in-array) validator for Yii 2

Notifications You must be signed in to change notification settings

chouaibi/yii2-blacklist-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

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 ...'],
        ];
    }

About

blacklist (not-in-array) validator for Yii 2

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages