chouaibi/yii2-blacklist-validator

There is no license information available for the latest version (1.0.0) of this package.

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

1.0.0 2015-12-20 15:36 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:12:47 UTC


README

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