vue validate js


 

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
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM