ValidAliasLocalPart.php 743 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Rules;
  3. use Illuminate\Contracts\Validation\Rule;
  4. class ValidAliasLocalPart 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 preg_match('/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))$/', $value);
  25. }
  26. /**
  27. * Get the validation error message.
  28. *
  29. * @return string
  30. */
  31. public function message()
  32. {
  33. return 'Invalid alias local part.';
  34. }
  35. }