UsersValidate.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 小夏 < 449134904@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\index\validate;
  12. use think\Validate;
  13. class UsersValidate extends Validate
  14. {
  15. protected $rule = [
  16. 'mobile' => 'require|mobile|length:11,20',
  17. 'code' => 'require|alphaNum|length:4,8',
  18. 'password' => 'require|pwd|length:4,20',
  19. 'realname' => 'require|chs',
  20. 'nickname' => 'require',
  21. 'account' => 'require|alphaNum|length:2,30',
  22. ];
  23. protected $message = [
  24. 'mobile.require' => '手机号码不为空',
  25. 'mobile.mobile' => '手机号码格式不正确',
  26. 'mobile.length' => '手机号码格式不正确',
  27. 'code.require' => '手机验证码不为空',
  28. 'code.alphaNum' => '手机验证码格式不正确',
  29. 'code.length' => '手机验证码格式不正确',
  30. 'password.require' => '登录密码不为空',
  31. 'password.pwd' => '登录密码格式不正确',
  32. 'password.length' => '登录密码格式不正确',
  33. 'now_address.require' => '请选择现居地址',
  34. 'now_address.*' => '现居地址格式不正确',
  35. 'home_address.require' => '请选择家乡地址',
  36. 'realname.require' => '真实姓名不为空',
  37. 'realname.chs' => '真实姓名格式不正确',
  38. 'nickname.require' => '请填写昵称',
  39. 'nickname.chs' => '昵称格式不正确',
  40. 'height.require' => '请填写身高信息',
  41. 'height.length' => '身高格式不正确',
  42. 'weight.require' => '请填写体重信息',
  43. 'weight.length' => '身高格式不正确',
  44. 'weight.integer' => '体重格式错误',
  45. 'sex.require' => '请选择性别',
  46. 'brithday.require' => '请选择出生日期',
  47. 'married.require' => '请选择婚姻状况',
  48. 'wechat_code.require' => '请填写微信号',
  49. 'idcard.require' => '请填写身份证号码',
  50. 'idcard.idcard' => '请填写正确格式的身份证号码',
  51. 'graduate.require' => '请填写毕业学校名称',
  52. 'eduacation.require' => '请选择您的学历',
  53. 'company.require' => '请填写就职公司名称',
  54. 'occupation.require' => '请选择职业',
  55. ];
  56. protected $regex = [
  57. 'mobile'=> '/^((13[0-9])|(14[5,7])|(15[0-9])|(16[6-8])|(17[0,1,3,5-8])|(18[0-9])|(19[1-9]))\\d{8}$/',
  58. 'pwd'=> '/^[0-9a-zA-Z][0-9a-zA-Z\_\!\@\#\$\%\^\&\*\(\)]{2,19}/',
  59. 'idcard'=> '/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/',
  60. ];
  61. protected $scene = [
  62. 'reg' => ['nickname','mobile','password'],
  63. 'login' => ['mobile','password'],
  64. ];
  65. }