| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | <?phpnamespace App\Validators\Rules;use Illuminate\Contracts\Validation\Rule;class MobileRule implements Rule{    /**     * Create a new rule instance.     *     * @return void     */    public function __construct()    {        //    }    /**     * Determine if the validation rule passes.     *     * @param  string  $attribute     * @param  mixed  $value     * @return bool     */    public function passes($attribute, $value)    {        //手机验证:第一位是1,第二个是(2|3|4|5|6|7|8|9)中的一个,位数是11位.        if (preg_match("/^1(2|3|4|5|6|7|8|9)\d{9}$/", $value)) {            return true;        }        return false;    }    /**     * Get the validation error message.     *     * @return string     */    public function message()    {        return '手机号码不正确';    }}
 |