Giter Site home page Giter Site logo

cli-phone-number-validator's Introduction

A CLI Phone Number Validator

Author Build Status Quality Score Software License Packagist Version Coverage Status

Installation

Install the application with composer:

$ composer create-project davidianbonner/cli-phone-number-validator

To create a standalone PHAR of the application for deployment, run:

$ php number-validator app:build number-validator

This will output a .PHAR to the build directory.

Usage

The validator comes with a pre-built GB & Channel Islands mobile command: validate:uk-mobile. There are two ways to process and validate numbers:

List source

Pass a list of phone numbers to the validator.

$ php number-validator validate:uk-mobile "07712345678" "07712341234" "07283 123 32"
File source

Pass a file with a phone number per-line.

$ php number-validator validate:uk-mobile ./path/to/file --file
Output directory

An output directory is required when using the standalone .PHAR:

$ php number-validator validate:uk-mobile ./path/to/file --file --output=/path/to/output/directory

Adding new validators

New validators can be added with minimal effort. First create a new command in app/Commands and extends the BaseValidatorCommand.

<?php

namespace App\Commands;

class ValidateESFixedLineCommand extends BaseValidatorCommand
{
    protected $signature = 'validate:es-fixedline
                            {source* : A list of numbers or files to validate against}
                            {--file : Specifies that the source is a list of files}
                            {--output= : Specifies that the output path}';

    protected $description = 'Validate Spanish fixed line numbers and ouput to a CSV';

    public function makeValidatorForNumer($number): PhoneNumberValidator
    {
        // The country code is only required when no dialing code is present in the number.
        return app(PhoneNumberValidator::class)->make($number, 'ES');
    }

    public function isNumberValid(PhoneNumberValidator $validator): bool
    {
        return ($validator->isValidFixedLine() && $validator->isValidForCountry('ES'));
    }
}

License

CLI Phone Number Validator is an open-sourced software licensed under the MIT license.

cli-phone-number-validator's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.