我有一个名为
imsi
这是一个
string
我只想在其中添加数字
[['imsi'], 'match','pattern'=> '[0-9]','message'=>'IMSI must include only numbers'],
现在,当我尝试创建新记录并插入
imsi公司
无论有无数字,它都会给我错误信息。
我的型号是
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']],
];
}
我怎样才能完全匹配该模式?
任何帮助都将不胜感激。