1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
class Card extends Validate {
protected $rule = [ 'name' => ['require', 'chs', 'min:2'], 'cardNo' => ['require', 'number', 'length:14,19'], ];
protected $message = [ 'name.require' => '姓名未填写', 'name.chs' => '姓名必须是中文', 'name.min' => '姓名最少两个汉字', 'cardNo.require' => '银行卡号必须填写', 'cardNo.number' => '银行卡必须是纯数字', 'cardNo.length' => '银行卡输入长度不正确' ];
protected $scene = [ 'addCard' => ['name', 'cardNo'] ]; }
use app\api\validate\user\Card as ValidateCard;
public function add(array $data){ $this->validata($data); } public function validata(array $data){ $validate = new ValidateCard; if (!$validate->scene('addCard')->check($data)) { throwError($validate->getError()); } }
|