marcel-strahl/temporary-email-validator-bundle

add temporary email address validator for symfony

v1.1.0 2022-03-29 19:30 UTC

This package is auto-updated.

Last update: 2024-03-29 04:19:56 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.