zero-to-prod/validate-email-cli

A CLI for Validating an Email

v1.1.0 2025-01-27 00:00 UTC

This package is auto-updated.

Last update: 2025-09-02 11:15:26 UTC


README

Repo GitHub Actions Workflow Status GitHub Actions Workflow Status GitHub Actions Workflow Status Packagist Downloads php Packagist Version License wakatime Hits-of-Code

Contents

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.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a new Pull Request.