Yii 1.1: luhn-number-validator

Validates Luhn numbers used in all kinds of number (ICCID, IMEI, ...)

LuhnNumberValidator - Validates Luhn numbers

Numbers like IMEI, ICCID, French SIREN, French SIRET, visa, ... can be checked with this extension.


Works with Yii 1.11 and above (and probably below).


Use this validator as most validators.

In rules of a model, do:

public function rules() {
 return array(
   array( 'imei','LuhnNumber',
          /* 'length'=>19, 'pattern'=>'/^\d+$/' */


  • 'imei' is the name of the attribute (or attribute list)
  • 'type' is the type of the number ('IMEI', 'ICCID', 'SIRET', 'SIREN', or none)
  • 'allowEmpty' if the value can be empty or not
  • 'length' length of the number (if absent: any length if not given by 'type')
  • 'pattern' pattern that the number must match (default match=number of digits expected in length).

Be the first person to leave a comment

Please to leave your comment.

Create extension