Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Providers;
  4.  
  5. use Illuminate\Support\ServiceProvider;
  6. use Illuminate\Support\Facades\Validator;
  7.  
  8. class AppServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * Bootstrap any application services.
  12. *
  13. * @return void
  14. */
  15. public function boot()
  16. {
  17. // Custom validation for alpha and spaces
  18. // Then insert 'alpha_spaces' => 'The :attribute may only contain letters and spaces.' to validation.php file,
  19. Validator::extend('alpha_spaces', function ($attribute, $value) {
  20.  
  21. // This will only accept alpha and spaces.
  22. // If you want to accept hyphens use: /^[\pL\s-]+$/u.
  23. return preg_match('/^[\pL\s]+$/u', $value);
  24. });
  25. }
  26.  
  27. public function register()
  28. {
  29. //
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement