2017 © Pedro Peláez
 

library laravel-validate-email-domain

Validates email addresses belong to the given domain

image

jtn/laravel-validate-email-domain

Validates email addresses belong to the given domain

  • Friday, October 20, 2017
  • by jtn
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 200 % Grown

The README.md

Laravel Email Domain Validation

Validation rule for Laravel 5.5 to validate that a given email address belongs to the provided domain., (*1)

Wildcard domains and multiple domains are supported., (*2)

Basic Usage

If your class implements the Laravel ValidatesRequests trait you can validate a simple domain as follows., (*3)

use Jtn\EmailDomain;

$this->validate(request()->all(), [
    'email' => ['email', new EmailDomain('example.com')]
])

This validation rule will only pass if the email provided is @example.com., (*4)

Wildcard Usage

$this->validate(request()->all(), [
    'email' => ['email', new EmailDomain('*.example.com')]
])

This rule wil match any of mail.example.com, test.example.com, etc. To match mail.test.example.com the rule must be new EmailDomain('*.*.example.com')., (*5)

Match Multiple Domains

To match multiple domains simply pass an array of accepted domains to the constructor. You can pass any number of domains and wildcards as an array to check them all., (*6)

$this->validate(request()->all(), [
    'email' => [
        'email',
        new EmailDomain(['example.org', 'example.com'])
    ]
])

Strict Mode

Strict mode can be disabled to match wildcard domains. This is useful if you would like to match all subdomains under example.com., (*7)

The following example will match example.com domains and any length of subdomains under it., (*8)

$domainRule = new EmailDomain(['example.com', ['*.example.com']]);
$this->validate(request()->all(), [
    'email' => ['email', $domainRule->nonStrict()]
])

Changelog

1.1.0

  • Add support for strict matching

1.0.0

  • Initial release, support for simple domains and wildcard

The Versions

20/10 2017

dev-master

9999999-dev

Validates email addresses belong to the given domain

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Jonathan Janssens

laravel email validator validation email domain

20/10 2017

v1.1.0

1.1.0.0

Validates email addresses belong to the given domain

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Jonathan Janssens

laravel email validator validation email domain

18/10 2017

v1.0.0

1.0.0.0

Validates email addresses belong to the given domain

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Jonathan Janssens

laravel email validator validation email domain