<commit_before>Yii Brazilian Validators
=========================

Yii 1.1 Extension that provides validators for Brazilian localization.

* CPF: Cadastro de Pessoa Física (like a Security Social Number in USA) 
* CNPJ: Cadastro Nacional de Pessoa Jurídica
* landlines: beginning with 2 and 3
* cellphones: 9 digits or 8 digits beginning with 7, 8 or 9

Installation
------------

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

[![Latest Stable Version](https://poser.pugx.org/igorsantos07/yii-br-validator/v/stable.svg)](https://packagist.org/packages/igorsantos07/yii-br-validator)
[![Total Downloads](https://poser.pugx.org/igorsantos07/yii-br-validator/downloads.svg)](https://packagist.org/packages/igorsantos07/yii-br-validator)

Either run this:

```
php composer.phar require --prefer-dist igorsantos07/yii-br-validator:1.*
```

or add this to the "require" section of your `composer.json` file.

```
"yiibr/yii-br-validator": "1.*"
```

Usage
-----

Add the rules as the following example:

```php

class PersonForm extends CModel {

	public $cpf;
	public $cnpj;
	public $cellphone;
	public $landline;
	public $phone;
	public $areaCode;

	// For maximum readability, you should create an alias for the validator folder :)
	// Here we are assuming you have at least an alias for your vendor folder.
	public function rules() {
		return array(
			// CPF validator
			array('cpf', 'vendor.igorsantos07.yii-br-validator.CpfValidator'),
			// CNPJ validator
			array('cnpj', 'vendor.igorsantos07.yii-br-validator.CnpjValidator'),
			// Cellphone-only validator, checking area code inside the field
			array('cellphone', 'vendor.igorsantos07.yii-br-validator.PhoneValidator', 'type' => PhoneValidator::TYPE_CELLPHONE),
                        // Cellphone-only validator, not validating area code
                        array(
				'cellphone',
				'vendor.igorsantos07.yii-br-validator.PhoneValidator',
				'type'     => PhoneValidator::TYPE_CELLPHONE,
				'areaCode' => false
			),
                        // Landline-only validator
                        array('landline', 'vendor.igorsantos07.yii-br-validator.PhoneValidator', 'type' => PhoneValidator::TYPE_LANDLINE),
                        // Any phone validator - cellphone or landline
                        array('phone', 'vendor.igorsantos07.yii-br-validator.PhoneValidator'),
                        // Cellphone validator with external area code check
                        array(
				'cellphone',
				'vendor.igorsantos07.yii-br-validator.PhoneValidator',
				'type'              => PhoneValidator::TYPE_CELLPHONE,
				'areaCodeAttribute' => 'areaCode'
			),
		);
	}
}
```
<commit_msg>Reducing whitespace on code sample<commit_after>Yii Brazilian Validators
=========================

Yii 1.1 Extension that provides validators for Brazilian localization.

* CPF: Cadastro de Pessoa Física (like a Security Social Number in USA) 
* CNPJ: Cadastro Nacional de Pessoa Jurídica
* landlines: beginning with 2 and 3
* cellphones: 9 digits or 8 digits beginning with 7, 8 or 9

Installation
------------

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

[![Latest Stable Version](https://poser.pugx.org/igorsantos07/yii-br-validator/v/stable.svg)](https://packagist.org/packages/igorsantos07/yii-br-validator)
[![Total Downloads](https://poser.pugx.org/igorsantos07/yii-br-validator/downloads.svg)](https://packagist.org/packages/igorsantos07/yii-br-validator)

Either run this:

```
php composer.phar require --prefer-dist igorsantos07/yii-br-validator:1.*
```

or add this to the "require" section of your `composer.json` file.

```
"yiibr/yii-br-validator": "1.*"
```

Usage
-----

Add the rules as the following example:

```php
class PersonForm extends CModel {

  public $cpf;
  public $cnpj;
  public $cellphone;
  public $landline;
  public $phone;
  public $areaCode;

  // For maximum readability, you should create an alias for the validator folder :)
  // Here we are assuming you have at least an alias for your vendor folder.
  public function rules() {
    return array(
      // CPF validator
      array('cpf', 'vendor.igorsantos07.yii-br-validator.CpfValidator'),
      // CNPJ validator
      array('cnpj', 'vendor.igorsantos07.yii-br-validator.CnpjValidator'),
      // Cellphone-only validator, checking area code inside the field
      array('cellphone', 'vendor.igorsantos07.yii-br-validator.PhoneValidator', 'type' => PhoneValidator::TYPE_CELLPHONE),
      // Cellphone-only validator, not validating area code
      array(
        'cellphone',
        'vendor.igorsantos07.yii-br-validator.PhoneValidator',
        'type'     => PhoneValidator::TYPE_CELLPHONE,
        'areaCode' => false
      ),
      // Landline-only validator
      array('landline', 'vendor.igorsantos07.yii-br-validator.PhoneValidator', 'type' => PhoneValidator::TYPE_LANDLINE),
      // Any phone validator - cellphone or landline
      array('phone', 'vendor.igorsantos07.yii-br-validator.PhoneValidator'),
      // Cellphone validator with external area code check
      array(
        'cellphone',
        'vendor.igorsantos07.yii-br-validator.PhoneValidator',
        'type'              => PhoneValidator::TYPE_CELLPHONE,
        'areaCodeAttribute' => 'areaCode'
      ),
    );
  }
}
```

{'fraction_non_alphanumeric': 0.1319418561311964, 'fraction_numerical': 0.013045098770033545, 'mean_word_length': 3.2460443037974684, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '998439', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1681, 'n_words': 408}