ChsDash.php 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Rules;
  3. use Illuminate\Contracts\Validation\Rule;
  4. class ChsDash implements Rule
  5. {
  6. /**
  7. * Create a new rule instance.
  8. *
  9. * @return void
  10. */
  11. public function __construct()
  12. {
  13. //
  14. }
  15. /**
  16. * Determine if the validation rule passes.
  17. *
  18. * @param string $attribute
  19. * @param mixed $value
  20. * @return bool
  21. */
  22. public function passes($attribute, $value)
  23. {
  24. $rules = "/^[\x{4e00}-\x{9fa5}a-zA-Z0-9\s\x{3002}\x{ff1f}\x{ff01}\x{ff0c}\x{3001}\x{ff1b}\x{ff1a}\x{201c}\x{201d}\x{2018}\x{2019}\x{ff08}\x{ff09}\x{300a}\x{300b}\x{3008}\x{3009}\x{3010}\x{3011}\x{300e}\x{300f}\x{300c}\x{300d}\x{fe43}\x{fe44}\x{3014}\x{3015}\x{2026}\x{2014}\x{ff5e}\x{fe4f}\x{ffe5}]+$/u";
  25. return preg_match($rules, $value);
  26. }
  27. /**
  28. * Get the validation error message.
  29. *
  30. * @return string
  31. */
  32. public function message()
  33. {
  34. return trans('validation.chsdash');
  35. }
  36. }