2017 © Pedro Peláez
 

yii2-extension yii2-translit-validator

Yii2 validator that transliterates model attribute values.

image

herroffizier/yii2-translit-validator

Yii2 validator that transliterates model attribute values.

  • Tuesday, March 29, 2016
  • by herroffizier
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2,599 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 9 % Grown

The README.md

Yii2 Attribute Index Validator

Build Status Scrutinizer Code Quality Code Coverage Code Climate, (*1)

This validator takes value from one attribute and puts transliterated value to another attribute. Also, validator may prepare transliterated string for usage in URL. Transliteration is made by URLify., (*2)

Installation

Install validator with Composer:, (*3)

composer require --prefer-dist "herroffizier/yii2-translit-validator:@stable"

Usage

Add validator to your model's rules array before required validator (if any) and set its sourceAttribute property to point source attribute which value should be transliterated., (*4)

use herroffizier\yii2tv\TranslitValidator;

...

public function rules()
{
    return [
        [['attribute'], 'required'],
        [
            ['attribute_translit'], 
            TranslitValidator::className(), 
            'sourceAttribute' => 'attribute'
        ],
        [['attribute_translit'], 'required'],
    ];
}

Validator has a few options to customize its behavior., (*5)

  • sourceAttribute as mentioned above points to source attribute which value should be transliterated. Empty by default and required.
  • lowercase enforces lower case for transliterated string. Default is true.
  • forUrl replaces all invalid characters with invalidReplacement value. Default is true.
  • invalidReplacement is a replacement for invalid characters. Used in conjunction with forUrl. Default is -.
  • invalidRegexp is a regular expression which matches all incorrect symbols for URL. Used in conjunction with forUrl. Default is /[^a-z0-9]+/i which matches all non-alphanumeric symbols.
  • trimInvalid trims invalid characters at beginning and at end of given string. Used in conjunction with forUrl. Default is false which means that no characters will be trimmed.

The Versions

29/03 2016

dev-develop

dev-develop

Yii2 validator that transliterates model attribute values.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 validator yii yii 2 translit slug urlify transliteration

29/03 2016

dev-master

9999999-dev

Yii2 validator that transliterates model attribute values.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 validator yii yii 2 translit slug urlify transliteration

29/03 2016

1.0.0

1.0.0.0

Yii2 validator that transliterates model attribute values.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 validator yii yii 2 translit slug urlify transliteration