I have a column named imsi
which is a string
and I want to add only numbers in it so for that I used
[['imsi'], 'match','pattern'=> '[0-9]','message'=>'IMSI must include only numbers'],
Now, when I try to create a new record and insert the imsi
number with or without numbers it will always give me the error message.
My model is
public function rules()
{
return [
[['imsi','operator_name','data_details','sms_details','status'], 'required'],
[['created_by', 'updated_by', 'sim_stauts', 'issued_to', 'returned_by', 'historic','data_details'
,'sms_details','monthly_bill','bill_date','credit_limit'], 'integer'],
[['created_at', 'updated_at','returned_at'], 'safe'],
[['imsi'], 'match','pattern'=> '[0-9]','message'=>'IMSI must include only numbers'],
[['operator_name'], 'string', 'max' => 20],
[['sim_number', 'status','plan_name','imsi'], 'string', 'max' => 50],
//[['monthly_bill'], 'string', 'max' => 100],
//[['imsi'], 'unique'],
[['created_by'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['created_by' => 'id']],
];
}
How can I exactly match the pattern?
Any help would be highly appreciated.