export default class Validator {
    static required(val, msg) {
        if ((!val && val != 0) || val.length === 0) {
            throw msg
        }
        return this
    }

    static mobile(val) {
        if (!val || val.length !== 11 || !/^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(val)) {
            throw '必须是11位手机号码'
        }
        return this
    }
}

 

posted on 2020-06-05 20:48  jzfan  阅读(935)  评论(0编辑  收藏  举报