zero-to-prod / validate-email-cli
A CLI for Validating an Email
Fund package maintenance!
Github
Requires
- php: >=8.1
- ext-json: *
- symfony/console: ^7.2
- zero-to-prod/package-helper: ^1.1.3
- zero-to-prod/regex-email: ^71.1
- zero-to-prod/validate-email: ^71.0
Requires (Dev)
- phpunit/phpunit: <12.0
README
Contents
- Introduction
- Requirements
- Installation
- Documentation Publishing
- Usage
- Docker Image
- Local Development
- Image Development
- Contributing
Introduction
A cli for validating an email.
Requirements
- PHP 8.1 or higher.
Installation
Install Zerotoprod\ValidateEmailCli
via Composer:
composer require zero-to-prod/validate-email-cli
This will add the package to your project's dependencies and create an autoloader entry for it.
Documentation Publishing
You can publish this README to your local documentation directory.
This can be useful for providing documentation for AI agents.
This can be done using the included script:
# Publish to default location (./docs/zero-to-prod/validate-email-cli) vendor/bin/zero-to-prod-validate-email-cli # Publish to custom directory vendor/bin/zero-to-prod-validate-email-cli /path/to/your/docs
Automatic Documentation Publishing
You can automatically publish documentation by adding the following to your composer.json
:
{ "scripts": { "post-install-cmd": [ "zero-to-prod-validate-email-cli" ], "post-update-cmd": [ "zero-to-prod-validate-email-cli" ] } }
Usage
Run this command to see the available commands:
vendor/bin/validate-email-cli list
Available Commands
This CLI provides three main commands for email validation and project information:
validate-email-cli:src
Displays the project's GitHub repository URL.
Usage:
vendor/bin/validate-email-cli validate-email-cli:src
Arguments: None
Example:
$ vendor/bin/validate-email-cli validate-email-cli:src https://github.com/zero-to-prod/validate-email-cli
validate-email-cli:show-regex
Shows the regex pattern used to validate email addresses.
Usage:
vendor/bin/validate-email-cli validate-email-cli:show-regex
Arguments: None
Example:
$ vendor/bin/validate-email-cli validate-email-cli:show-regex /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/
validate-email-cli:validate
Validates an email address. Returns the email when valid, empty string otherwise.
Usage:
vendor/bin/validate-email-cli validate-email-cli:validate <email>
Arguments:
email
(required) - The email address to validate
Examples:
# Valid email $ vendor/bin/validate-email-cli validate-email-cli:validate user@example.com user@example.com # Invalid email $ vendor/bin/validate-email-cli validate-email-cli:validate invalid-email [empty output] # Complex valid email $ vendor/bin/validate-email-cli validate-email-cli:validate john.doe+newsletter@sub.domain.com john.doe+newsletter@sub.domain.com
Docker Image
You can also run the cli using the docker image:
docker run --rm davidsmith3/validate-email-cli
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.