Skip to content

CreditCard

Pieter Hordijk edited this page Dec 30, 2018 · 1 revision

TOC

AmericanExpress

Validates the input (string without formatting) to be a valid American Express credit card number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\CreditCard\AmericanExpress;

(new AmericanExpress())->validate('340000000000009');

Failure reasons

  • Type.String when the validated value is not a string
  • CreditCard.AmericanExpress when the validated value is not a valid American Express credit card number
  • CreditCard.LuhnChecksum when the validated value's checksum digit is not valid

DinersClub

Validates the input (string without formatting) to be a valid Diners Club credit card number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\CreditCard\DinersClub;

(new DinersClub())->validate('30000000000004');

Failure reasons

  • Type.String when the validated value is not a string
  • CreditCard.DinersClub when the validated value is not a valid Diners Club credit card number
  • CreditCard.LuhnChecksum when the validated value's checksum digit is not valid

Discover

Validates the input (string without formatting) to be a valid Discover credit card number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\CreditCard\Discover;

(new Discover())->validate('6011000000000004');

Failure reasons

  • Type.String when the validated value is not a string
  • CreditCard.Discover when the validated value is not a valid Discover credit card number
  • CreditCard.LuhnChecksum when the validated value's checksum digit is not valid

LuhnChecksum

Validates the input (string without formatting) to result in a valid Luhn checksum.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\CreditCard\LuhnChecksum;

(new LuhnChecksum())->validate('340000000000009');

Failure reasons

  • Type.String when the validated value is not a string
  • CreditCard.LuhnChecksum when the validated value is does not result in a valid Luhn checksum

MasterCard

Validates the input (string without formatting) to be a valid MasterCard credit card number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\CreditCard\MasterCard;

(new MasterCard())->validate('5500000000000004');

Failure reasons

  • Type.String when the validated value is not a string
  • CreditCard.MasterCard when the validated value is not a valid MasterCard credit card number
  • CreditCard.LuhnChecksum when the validated value's checksum digit is not valid

Visa

Validates the input (string without formatting) to be a valid Visa credit card number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\CreditCard\Visa;

(new Visa())->validate('4111111111111111');

Failure reasons

  • Type.String when the validated value is not a string
  • CreditCard.Visa when the validated value is not a valid Visa credit card number
  • CreditCard.LuhnChecksum when the validated value's checksum digit is not valid
Clone this wiki locally