首页 > 其他 > 详细

TP验证规则Validate

时间:2019-12-06 23:37:34      阅读:136      评论:0      收藏:0      [点我收藏+]
use think\Validate;

<?php
namespace app\common\model;

use think\Validate;
use think\Db;

class InvoiceRecords extends BaseModel
{
    protected $table = ‘t_invoice_record‘;

    protected $rule = [
        ‘type‘  => ‘in:1,2‘,
        ‘invoice_tel‘  => ‘mobile‘,
        ‘email‘  => ‘email‘,

    ];
    protected $message = [
        ‘type‘ => ‘开票类型错误‘,
        ‘invoice_tel‘ => ‘手机号错误‘,
        ‘email‘ => ‘邮箱格式错误‘,

    ];

    public function addInfoData($member_id, $type, $money, $invoice_name, $invoice_tel, $email, $taxpayer_number, $id)
    {
        $data = [
            ‘type‘ => $type,
            ‘invoice_tel‘ => $invoice_tel,
            ‘email‘ => $email,
        ];
        $validate = new Validate($this->rule, $this->message);
        if (!$validate->check($data)) {
            return [‘code‘ => 400, ‘msg‘ => $validate->getError()];
        }
    }
}

 

TP验证规则Validate

原文:https://www.cnblogs.com/camg/p/11999978.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!