CardScheme
extends Constraint
in package
Metadata for the CardSchemeValidator.
Tags
Table of Contents
Constants
- AMEX = 'AMEX'
- CHINA_UNIONPAY = 'CHINA_UNIONPAY'
- CLASS_CONSTRAINT = 'class'
- Marks a constraint that can be put onto classes.
- DEFAULT_GROUP = 'Default'
- The name of the group given to all constraints with no explicit group.
- DINERS = 'DINERS'
- DISCOVER = 'DISCOVER'
- INSTAPAYMENT = 'INSTAPAYMENT'
- INVALID_FORMAT_ERROR = 'a8faedbf-1c2f-4695-8d22-55783be8efed'
- JCB = 'JCB'
- LASER = 'LASER'
- MAESTRO = 'MAESTRO'
- MASTERCARD = 'MASTERCARD'
- MIR = 'MIR'
- NOT_NUMERIC_ERROR = 'a2ad9231-e827-485f-8a1e-ef4d9a6d5c2e'
- PROPERTY_CONSTRAINT = 'property'
- Marks a constraint that can be put onto properties.
- UATP = 'UATP'
- VISA = 'VISA'
Properties
- $groups : array<string|int, string>
- The groups that the constraint belongs to.
- $message : mixed
- $payload : mixed
- Domain-specific data attached to a constraint.
- $schemes : mixed
- $errorNames : mixed
- Maps error codes to the names of their constants.
Methods
- __construct() : mixed
- Initializes the constraint with options.
- __get() : mixed
- Returns the value of a lazily initialized option.
- __isset() : bool
- __set() : mixed
- Sets the value of a lazily initialized option.
- addImplicitGroupName() : mixed
- Adds the given group if this constraint is in the Default group.
- getDefaultOption() : string|null
- Returns the name of the default option.
- getErrorName() : string
- Returns the name of the given error code.
- getRequiredOptions() : array<string|int, string>
- Returns the name of the required options.
- getTargets() : string|array<string|int, string>
- Returns whether the constraint can be put onto classes, properties or both.
- validatedBy() : string
- Returns the name of the class that validates this constraint.
- normalizeOptions() : array<string|int, mixed>
Constants
AMEX
public
mixed
AMEX
= 'AMEX'
CHINA_UNIONPAY
public
mixed
CHINA_UNIONPAY
= 'CHINA_UNIONPAY'
CLASS_CONSTRAINT
Marks a constraint that can be put onto classes.
public
mixed
CLASS_CONSTRAINT
= 'class'
DEFAULT_GROUP
The name of the group given to all constraints with no explicit group.
public
mixed
DEFAULT_GROUP
= 'Default'
DINERS
public
mixed
DINERS
= 'DINERS'
DISCOVER
public
mixed
DISCOVER
= 'DISCOVER'
INSTAPAYMENT
public
mixed
INSTAPAYMENT
= 'INSTAPAYMENT'
INVALID_FORMAT_ERROR
public
mixed
INVALID_FORMAT_ERROR
= 'a8faedbf-1c2f-4695-8d22-55783be8efed'
JCB
public
mixed
JCB
= 'JCB'
LASER
public
mixed
LASER
= 'LASER'
MAESTRO
public
mixed
MAESTRO
= 'MAESTRO'
MASTERCARD
public
mixed
MASTERCARD
= 'MASTERCARD'
MIR
public
mixed
MIR
= 'MIR'
NOT_NUMERIC_ERROR
public
mixed
NOT_NUMERIC_ERROR
= 'a2ad9231-e827-485f-8a1e-ef4d9a6d5c2e'
PROPERTY_CONSTRAINT
Marks a constraint that can be put onto properties.
public
mixed
PROPERTY_CONSTRAINT
= 'property'
UATP
public
mixed
UATP
= 'UATP'
VISA
public
mixed
VISA
= 'VISA'
Properties
$groups
The groups that the constraint belongs to.
public
array<string|int, string>
$groups
$message
public
mixed
$message
= 'Unsupported card type or invalid card number.'
$payload
Domain-specific data attached to a constraint.
public
mixed
$payload
$schemes
public
mixed
$schemes
$errorNames
Maps error codes to the names of their constants.
protected
static mixed
$errorNames
= [self::NOT_NUMERIC_ERROR => 'NOT_NUMERIC_ERROR', self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR']
Methods
__construct()
Initializes the constraint with options.
public
__construct(array<string|int, mixed>|string|null $schemes[, string $message = null ][, array<string|int, mixed> $groups = null ][, mixed $payload = null ][, array<string|int, mixed> $options = [] ]) : mixed
You should pass an associative array. The keys should be the names of existing properties in this class. The values should be the value for these properties.
Alternatively you can override the method getDefaultOption() to return the name of an existing property. If no associative array is passed, this property is set instead.
You can force that certain options are set by overriding getRequiredOptions() to return the names of these options. If any option is not set here, an exception is thrown.
Parameters
- $schemes : array<string|int, mixed>|string|null
- $message : string = null
- $groups : array<string|int, mixed> = null
-
An array of validation groups
- $payload : mixed = null
-
Domain-specific data attached to a constraint
- $options : array<string|int, mixed> = []
-
The options (as associative array) or the value for the default option (any other type)
__get()
Returns the value of a lazily initialized option.
public
__get(string $option) : mixed
Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.
Parameters
- $option : string
Tags
__isset()
public
__isset(string $option) : bool
Parameters
- $option : string
Return values
bool__set()
Sets the value of a lazily initialized option.
public
__set(string $option, mixed $value) : mixed
Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.
Parameters
- $option : string
- $value : mixed
Tags
addImplicitGroupName()
Adds the given group if this constraint is in the Default group.
public
addImplicitGroupName(string $group) : mixed
Parameters
- $group : string
getDefaultOption()
Returns the name of the default option.
public
getDefaultOption() : string|null
Override this method to define a default option.
Return values
string|nullgetErrorName()
Returns the name of the given error code.
public
static getErrorName(string $errorCode) : string
Parameters
- $errorCode : string
Tags
Return values
stringgetRequiredOptions()
Returns the name of the required options.
public
getRequiredOptions() : array<string|int, string>
Override this method if you want to define required options.
Return values
array<string|int, string>getTargets()
Returns whether the constraint can be put onto classes, properties or both.
public
getTargets() : string|array<string|int, string>
This method should return one or more of the constants Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT.
Return values
string|array<string|int, string> —One or more constant values
validatedBy()
Returns the name of the class that validates this constraint.
public
validatedBy() : string
By default, this is the fully qualified name of the constraint class suffixed with "Validator". You can override this method to change that behavior.
Return values
stringnormalizeOptions()
protected
normalizeOptions(mixed $options) : array<string|int, mixed>
Parameters
- $options : mixed