yii-codice-fiscale-validator Simple class to validate the Italian tax code

  1. Usage in active record
  2. Static usage
  3. Todo

Codice Fiscale (tax code or CF) is the italian code used to uniquely identify citizens for tax and administrative purpose

This is a simple class that validates and generates the Italian tax code (codice fiscale)

GitHub Repository

Usage in active record

class Citizen extends CActiveRecord
{
	[...]
	public function rules()
	{
		return array(
			[...]
			array('tax_code', 'ext.CfValidator',
				'strict' => true,
				'validateWithAttrs' => array( // key value pairs [modelattributes => CfValidator local properties]
					'nome' => 'name',
					'cognome' => 'surname',
					'genere' => 'gender',
					'giorno_nascita' => 'dayOfBirth',
					'mese_nascita' => 'monthOfBirth',
					'anno_nascita' => 'yearOfBirth',
					'comune_nascita' => 'codeIstat',
				)
			)

		);
	}
	[...]
}

Static usage

Yii::import('ext.CfValidator');
$cf = new CfValidator();
$cf->strict = true;
$cf->gender = CfValidator::GENDER_MALE;
$cf->name = 'Mario';
$cf->surname = 'Rossi';
$cf->dayOfBirth = '01';
$cf->monthOfBirth = '01';
$cf->yearOfBirth = '1980';
$cf->codeIstat = 'H501';

if(!$cf->validateValue("MRARSS80A01H501T") {
	echo "Error TAX CODE shoud be: " . $cf->cf
}

Todo

  • Client Validation
0 0
4 followers
264 downloads
Yii Version: Unknown
License: MIT
Category: Validation
Developed by: toriphes
Created on: Feb 27, 2014
Last updated: 10 years ago

Downloads

show all

Related Extensions