Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Dropelikeit/temporary-email-validator-bundle

Repository files navigation

##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.

About

add temporary email address validator for Symfony

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages