NormalString.php 794 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Rules;
  3. use Illuminate\Contracts\Validation\Rule;
  4. class NormalString 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. return (findRegexString($value, _HANGUL_ + _ALPHABETIC_ + _NUMERIC_) === false ? false : true);
  25. }
  26. /**
  27. * Get the validation error message.
  28. *
  29. * @return string
  30. */
  31. public function message()
  32. {
  33. return ':attribute 은(는) 공백없이 한글, 영문, 숫자만 입력 가능합니다.';
  34. }
  35. }