{"id":32610532,"url":"https://github.com/maize-tech/laravel-email-domain-rule","last_synced_at":"2025-10-30T13:50:17.010Z","repository":{"id":41870748,"uuid":"377557854","full_name":"maize-tech/laravel-email-domain-rule","owner":"maize-tech","description":"A package to validate email domains in a user registration form","archived":false,"fork":false,"pushed_at":"2025-08-11T21:22:52.000Z","size":738,"stargazers_count":61,"open_issues_count":3,"forks_count":9,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-10-01T10:45:22.490Z","etag":null,"topics":["email","laravel","php","registration","rule","validation"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maize-tech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"maize-tech"}},"created_at":"2021-06-16T16:18:16.000Z","updated_at":"2025-05-12T15:11:25.000Z","dependencies_parsed_at":"2024-07-08T19:52:56.426Z","dependency_job_id":null,"html_url":"https://github.com/maize-tech/laravel-email-domain-rule","commit_stats":{"total_commits":21,"total_committers":4,"mean_commits":5.25,"dds":0.5238095238095238,"last_synced_commit":"af1ebf81425cbdffc4c7aca8a74cce1d5a91b6ac"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/maize-tech/laravel-email-domain-rule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-email-domain-rule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-email-domain-rule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-email-domain-rule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-email-domain-rule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maize-tech","download_url":"https://codeload.github.com/maize-tech/laravel-email-domain-rule/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-email-domain-rule/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281818074,"owners_count":26566858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","laravel","php","registration","rule","validation"],"created_at":"2025-10-30T13:50:15.440Z","updated_at":"2025-10-30T13:50:17.000Z","avatar_url":"https://github.com/maize-tech.png","language":"PHP","funding_links":["https://github.com/sponsors/maize-tech"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/art/socialcard-dark.png\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"/art/socialcard-light.png\"\u003e\n  \u003cimg src=\"/art/socialcard-light.png\" alt=\"Social Card of Laravel Email Domain Rule\"\u003e\n\u003c/picture\u003e\n\u003c/p\u003e\n\n\n# Laravel Email Domain Rule\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/maize-tech/laravel-email-domain-rule.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-email-domain-rule)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-email-domain-rule/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/maize-tech/laravel-email-domain-rule/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-email-domain-rule/php-cs-fixer.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/maize-tech/laravel-email-domain-rule/actions?query=workflow%3A\"Check+%26+fix+styling\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/maize-tech/laravel-email-domain-rule.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-email-domain-rule)\n\nThis package allows to define a subset of allowed email domains and validate any user registration form with a custom rule.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require maize-tech/laravel-email-domain-rule\n```\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --provider=\"Maize\\EmailDomainRule\\EmailDomainRuleServiceProvider\" --tag=\"email-domain-rule-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n```bash\nphp artisan vendor:publish --provider=\"Maize\\EmailDomainRule\\EmailDomainRuleServiceProvider\" --tag=\"email-domain-rule-config\"\n```\n\nThis is the content of the published config file:\n\n```php\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Email Domain model\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the fully qualified class name of the email domain model.\n    |\n    */\n\n    'email_domain_model' =\u003e Maize\\EmailDomainRule\\Models\\EmailDomain::class,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Email Domain wildcard\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the character used as wildcard for all email domains.\n    |\n    */\n\n    'email_domain_wildcard' =\u003e '*',\n\n    /*\n    |--------------------------------------------------------------------------\n    | Validation message\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the message thrown if the validation rule fails.\n    |\n    */\n\n    'validation_message' =\u003e 'The selected :attribute does not have a valid domain.',\n];\n```\n\n## Usage\n\n### Basic\n\nTo use the package, run the migration and fill in the table with a list of accepted email domains for your application.\n\nYou can then just add the custom validation rule to validate, for example, a user registration form.\n\n```php\nuse Maize\\EmailDomainRule\\EmailDomainRule;\nuse Illuminate\\Support\\Facades\\Validator;\n\n$email = 'my-email@example.com';\n\nValidator::make([\n    'email' =\u003e $email,\n], [\n    'email' =\u003e [\n        'string',\n        'email',\n        new EmailDomainRule,\n    ],\n])-\u003evalidated(); \n```\n\nThat's all!\nLaravel will handle the rest by validating the input and throwing an error message if validation fails.\n\n### Wildcard domains\n\nIf needed, you can optionally add wildcard domains to the `email_domains` database table: the custom rule will handle the rest.\n\nThe default wildcard character is an asterisk (`*`), but you can customize it within the `email_domain_wildcard` setting.\n\n```php\nuse Maize\\EmailDomainRule\\EmailDomainRule;\nuse Maize\\EmailDomainRule\\Models\\EmailDomain;\nuse Illuminate\\Support\\Facades\\Validator;\n\nEmailDomain::create(['domain' =\u003e '*.example.com']);\n\nValidator::make([\n    'email' =\u003e 'info@example.com',\n], [\n    'email' =\u003e ['string', 'email', new EmailDomainRule],\n])-\u003efails(); // returns true as the given domain is not in the list\n\nValidator::make([\n    'email' =\u003e 'info@subdomain.example.com',\n], [\n    'email' =\u003e ['string', 'email', new EmailDomainRule],\n])-\u003efails(); // returns false as the given domain matches the wildcard domain\n```\n\n### Model customization\n\nYou can also override the default `EmailDomain` model to add any additional field by changing the `email_domain_model` setting.\n\nThis can be useful when working with a multi-tenancy scenario in a single database system: in this case you can just add a `tenant_id` column to the migration and model classes, and apply a global scope to the custom model.\n\n```php\nuse Maize\\EmailDomainRule\\EmailDomainRule as BaseEmailDomain;\nuse Illuminate\\Database\\Eloquent\\Builder;\n\nclass EmailDomain extends BaseEmailDomain\n{\n    protected $fillable = [\n        'domain',\n        'tenant_id',\n    ];\n\n    protected static function booted()\n    {\n        static::addGlobalScope('tenantAware', function (Builder $builder) {\n            $builder-\u003ewhere('tenant_id', auth()-\u003euser()-\u003etenant_id);\n        });\n    }\n}\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/maize-tech/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](https://github.com/maize-tech/.github/security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Riccardo Dalla Via](https://github.com/riccardodallavia)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaize-tech%2Flaravel-email-domain-rule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaize-tech%2Flaravel-email-domain-rule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaize-tech%2Flaravel-email-domain-rule/lists"}