• Stars
    star
    780
  • Rank 58,299 (Top 2 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created about 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Manufacturing Industry, Phone numbers & Zipcodes for many countries

IsoCodes

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book Industry, Phone numbers & Zipcodes for many countries

Usage

// Sending letters to the Labrador Islands ?
$isCanadian = ZipCode::validate('A0A 1A0', 'CA');

// Checking out your e-commerce shopping cart?
$isBankable = CreditCard::validate('12345679123456');

// Transferring money worldwide?
$isSwiftBic = SwiftBic::validate('CEDELULLXXX');

// Paying your taxes in Madrid?
$isTaxableInSpain = Nif::validate('A999999L');

// Receiving containers from Port of Shanghai?
$isShippingContainerCode = Sscc::validate('806141411234567896');

// Publishing books?
$isPublished = Isbn::validate('2-2110-4199-X')

// Trading items with GTIN barcodes in GS1 system?
$isBarcode = Ean13::validate('4719512002889')

// Calling phone numbers in Palo Alto?
$isPhonable = PhoneNumber::validate('+1-650-798-2800', 'US')

// Buying Apple stocks?
$isISIN = Isin::validate('US0378331005'); // Apple Inc. (AAPL)

// Trading Apple products?
$isCUSIP = Cusip::validate('037833100'); // Apple Inc. (AAPL)

// Checking your iPhone device is valid?
$isDevice = Imei::validate('352066060926230');

// Selling your Honda Civic?
$isVin = VinNA::validate('1HGBH41JXMN109186');    

ISO Codes Validations available:

International Finance

  • IBAN (requires bcmath PHP extension)
  • SWIFT/BIC
  • BBAN (RIB, requires bcmath PHP extension)
  • Credit Card number
  • SEDOL (Stock Exchange codes)

Manufacturing Industries

  • ISBN - International Standard Book Number, both 10 & 13 digits
  • ISMN - International Standard Music Number
  • ISWC - International Standard Musical Work Code
  • IMEI - International Mobile Equipment Identity
  • VIN - Vehicle Identification Number – ISO 3779 & ISO 4030

Public Administrations

  • ISIN - International Securities Identification Number
  • Country-specific VAT / tax system: various VAT number formats
  • France: Numéro de Sécurité Sociale / INSEE, SIREN, SIRET, Codes postaux, Clef Type 1/2 Norme B2
  • US: Social Security number
  • UK: National Insurance Number (NINO)
  • Belgium: Structured Ccommunication ("communication structurée")
  • Spain: NIF, NIE (Número de Identificación Fiscal/Extranjero) & CIF (Código de identificación fiscal)
  • Netherlands: Burgerservicenummer / Citizen Service Number (BSN)
  • Finland: HETU, Henkilötunnus (Finnish personal identity code)
  • Switzerland: Business Orgs UID (VAT) Number / Unternehmens-Identifikationsnummer

GS1 specific numbers/identifiers

  • GTIN - Global Trade Item Number: GTIN-8, GTIN-12, GTIN-13, GTIN-14
  • GLN - Global Location Number
  • SSCC - Serial Shipping Container Code
  • GRAI - Global Returnable Asset Identifier
  • GSRN - Global Service Relation Number
  • GDTI - Global Document Type Identifier
  • UDI - Unique Device Identification (the GTIN part of it)
  • Older/deprecated identifiers, now in GTIN: EAN-8, EAN-13, UCC-13, UPC-A, DUN-14, ITF-14

Miscellaneous

  • ZIP code validators for 175+ countries
  • Phone number validation for all countries/regions of the world

Each code has its own validator. Each validator is illustrated by a unit test case.

IsoCodes is compatible with all versions of PHP that are actively supported by the PHP project.

Build status

License Latest Stable Version Build Status Scrutinizer Code Quality SymfonyInsight Coverage Status Total Downloads Monthly Downloads Daily Downloads

Continously inspecting results (phpdoc, phpmd, phpcc, etc.) available on Scrutinizer CI

bcmath as an optional extension for certain validators

For IBAN & BBAN ISO-codes, PHP is required to be compiled with "--enable-bcmath" for arbitrary precision mathematic checks. Usually, you already have bcmath bundled in your PHP version, since many common PHP packages (php-cli, php-fpm, php5-cgi, libapache2-mod-php5, etc.) in stable GNU/Linux distribution releases (such as Debian) are listed as having bcmath built in to them, as an included module.

Installing

Via GitHub

$ git clone [email protected]:ronanguilloux/IsoCodes.git

Autoloading is PSR-0 friendly.

Via Packagist & Composer

Require the latest version of ronanguilloux/isocodes with Composer

$ composer require ronanguilloux/isocodes

Wrappers

With Symfony Validator

Install Soullivaneuh/IsoCodesValidator to get IsoCodes working as Validator for Symfony and Silex.

With CakePHP 3

Install gourmet/validation to get IsoCodes working with CakePHP 3 as a validator.

With Laravel

Install pixelpeter/laravel5-isocodes-validation to get IsoCodes working with Laravel 5 as a validator.

Supported PHP versions

  • 7.3
  • 7.4

Unit testing

$ phpunit --testdox --coverage-text

Make utilities

For development & contribution purpose only, a Makefile provides various tools to check your code style, quality & test coverage:

Usual tasks:

	To initialize vendors:  make
	To check code quality:	make quality
	To run tests suite:	    make tests
	To fix code style:	    make cs-fix

Other specific tasks:

	To evaluate code coverage:			        make codecoverage
	To run a simple continuous tests server:	make continuous
	To dry-fix code style issues:			    make dry-fix
	To evaluate code quality stats:			    make stats
	To update vendors using Composer:		    make update

Quality assurance report

Isocodes quality plan is mainly based on phpunit: it runs 980+ unit tests, with separated valid & invalid entry sets. Test values are mainly real data or documented examples from standard documentation, and a few handmade values.

The composer.json already includes these Php Quality Assurance Toolchain libraries:

Just run:

$ make stats -i

XML report outputs are then generated in a new ./build folder

Code covering report built using Coveralls.io. How-to generate such code coverage report using PHPUnit.

License Information

Contributing Code

The issue queue can be found at: https://github.com/ronanguilloux/IsoCodes/issues. See CONTRIBUTING.md.

Special thanks

Contributors list: Many thanks to all!

Many thanks to JetBrains PhpStorm for having sponsored the IsoCode library development from the very beginning! Any contributor having an accepted PR may receive an Open Source License Key for PhpStorm IDE. Just ping Ronan via email to get one.

More Repositories

1

temperature-pi

Raspberry Pi based temperature logger using a DS18B20 1-Wire digital temperature sensor
PHP
22
star
2

php-gpio-web

Website integration example of the php-gpio lib
PHP
18
star
3

akeneo-pim-docker

Akeneo PIM CE 1.6 last stable, with PHP 7, in a single Docker container
Shell
16
star
4

SilexMarkdown

Markdown-generated dynamic website, using damn simple markdown files & Silex micro-framework
PHP
16
star
5

Docker-Symfony-PostgreSQL-ELK

Docker multi-container stack for Symfony2 - NGINX, PHP-FPM, PostgreSQL & ElasticSearch-Logstash-Kibana
Makefile
13
star
6

dotfiles

My commented dotfiles (bash, vim, git, etc.)
Vim Script
10
star
7

Raspberry-Pi-Utils

Raspi related librairies & tools
C
9
star
8

OpenWines

French Vineyards Open Data - HATEOAS RESTful API
PHP
7
star
9

NodeOpenDoc

Digital asset management, document-oriented, nodejs-based API & Web app.
JavaScript
5
star
10

PhpLib

Simple PHP lib, tools & helpers
PHP
4
star
11

Bin

my local ~/Bin scripts, conf files & install notes
PHP
4
star
12

rgIsoCodes

THIS EXTENSION IS NO LONGER MAINTAINED
PHP
3
star
13

pleasenofb.com

A no-facebook-please web app, to run locally
3
star
14

Bookmarklets

Usefull bookmarks that use Js
2
star
15

debianeo

Debian Docker image for Akeneo instances
Shell
2
star
16

Open-Source-In-A-Web-Agency

Open source adventures in a web agency
JavaScript
2
star
17

akeneo-college-internship-program

2
star
18

Vagrant-Lamp-Stack

Yet another Puppet based Vagrant's configuration (ubuntu64-server)
Puppet
2
star
19

csv-utils

Quick CSV manipulation via CLI
PHP
2
star
20

GeocoderToolkit

Geo-related utils & toolkit PHP library, build atop the Geocoder lib
PHP
2
star
21

Compiti

Ionic, AngularJs-based homework assignments app for my 8 years old little girl
JavaScript
1
star
22

pim2xml

Create XML outputs out of XSD + PIM products
PHP
1
star
23

Javascript-helpers

Various Js contribs
JavaScript
1
star
24

euradionantes

EuradioNantes.eu Web Platform: tech debt free version. WIP!
1
star
25

ensemble-boni.org

ensemble-boni.org website & more:
1
star
26

algorithms

PHP
1
star
27

ShakeTheNations

Latest Earthquakes Feeds Parser & Analyzer
PHP
1
star
28

alpineo

Alpine Docker image for Akeneo instances
Shell
1
star
29

SvgGraphics

Various Free & Open Source SVG graphics
Shell
1
star
30

RevealLeap

RevealJS Leamp Motion Controller
JavaScript
1
star
31

Guacamole

Gestion documentaire
JavaScript
1
star
32

rgWebCheck

Website checker, allowing you to add your own tests & benchmarks. GNU Affero GPL'd.
PHP
1
star
33

rgMailHide

rgMailHide for eZPublish : Simple eZ Publish wrapper extension for reCAPTCHA Mailhide
1
star