marcel-strahl/temporary-email-validator-bundle

add temporary email address validator for symfony

v1.0.1 2021-06-18 11:51 UTC

This package is auto-updated.

Last update: 2021-07-18 12:04:12 UTC


README

##Recognition of temporary e-mail addresses as validator for Symfony

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock License Gitworkflow

It is compatible and tested with PHP 8.+ on Symfony 5.x.

###Installation:

composer require marcel-strahl/temporary-email-validator

If Symfony/Flex is not enabled, the bundle will not be loaded automatically. So it is necessary to enter this in the config/bundes.php yourself, that you can do with the following line:

return [
    // Some other bundles [...]
    MarcelStrahl\TemporaryEmailValidatorSymfony\TemporaryEmailValidatorBundle::class => ['all' => true],  
];

You can easily use the validator via annotation with the help of the doctrine/annotations bundle. The following is an annotation example:

namespace App\Controller;

use MarcelStrahl\TemporaryEmailValidatorSymfony\Validator\IsNotTemporaryEmail;

final class TestDto
{
    /**
    * @IsNotTemporaryEmail 
    */
    private string $email;

    private function __construct(string $email)
    {
        $this->email = $email;
    }

    public static function create(string $email): self
    {
        return new self($email);
    }

    public function getEmail(): string
    {
        return $this->email;
    }
}

The following is an attribute example:

     namespace App\Controller;

use MarcelStrahl\TemporaryEmailValidatorSymfony\Validator\IsNotTemporaryEmail;

final class TestDto
{
    #[IsNotTemporaryEmail]
    private string $email;

    private function __construct(string $email)
    {
        $this->email = $email;
    }

    public static function create(string $email): self
    {
        return new self($email);
    }

    public function getEmail(): string
    {
        return $this->email;
    }
}

###Hint:

I am not the creator of the "Temporary Email Detection" but have changed the following package into a Symfony Validator!

Main Package Temporary E-Mail Detection: https://github.com/jprangenbergde/temporary-email-detection

Credits

License

This bundle is under the MIT license.
For the whole copyright, see the LICENSE file distributed with this source code.