class CardScheme
Validates a credit card number for a given credit card company.
@author Tim Nagel <t.nagel@infinite.net.au> @author Bernhard Schussek <bschussek@gmail.com>
Hierarchy
- class \Symfony\Component\Validator\Constraint
- class \Symfony\Component\Validator\Constraints\CardScheme extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of CardScheme
File
-
vendor/
symfony/ validator/ Constraints/ CardScheme.php, line 22
Namespace
Symfony\Component\Validator\ConstraintsView source
class CardScheme extends Constraint {
public const AMEX = 'AMEX';
public const CHINA_UNIONPAY = 'CHINA_UNIONPAY';
public const DINERS = 'DINERS';
public const DISCOVER = 'DISCOVER';
public const INSTAPAYMENT = 'INSTAPAYMENT';
public const JCB = 'JCB';
public const LASER = 'LASER';
public const MAESTRO = 'MAESTRO';
public const MASTERCARD = 'MASTERCARD';
public const MIR = 'MIR';
public const UATP = 'UATP';
public const VISA = 'VISA';
public const NOT_NUMERIC_ERROR = 'a2ad9231-e827-485f-8a1e-ef4d9a6d5c2e';
public const INVALID_FORMAT_ERROR = 'a8faedbf-1c2f-4695-8d22-55783be8efed';
protected const ERROR_NAMES = [
self::NOT_NUMERIC_ERROR => 'NOT_NUMERIC_ERROR',
self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
];
public string $message = 'Unsupported card type or invalid card number.';
public array|string|null $schemes = null;
/**
* @param non-empty-string|non-empty-string[]|array<string,mixed>|null $schemes Name(s) of the number scheme(s) used to validate the credit card number
* @param string[]|null $groups
* @param array<string,mixed> $options
*/
public function __construct(array|string|null $schemes, ?string $message = null, ?array $groups = null, mixed $payload = null, array $options = []) {
if (\is_array($schemes) && \is_string(key($schemes))) {
$options = array_merge($schemes, $options);
}
else {
$options['value'] = $schemes;
}
parent::__construct($options, $groups, $payload);
$this->message = $message ?? $this->message;
}
public function getDefaultOption() : ?string {
return 'schemes';
}
public function getRequiredOptions() : array {
return [
'schemes',
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
CardScheme::$message | public | property | |||
CardScheme::$schemes | public | property | |||
CardScheme::AMEX | public | constant | |||
CardScheme::CHINA_UNIONPAY | public | constant | |||
CardScheme::DINERS | public | constant | |||
CardScheme::DISCOVER | public | constant | |||
CardScheme::ERROR_NAMES | protected | constant | Maps error codes to the names of their constants. | Overrides Constraint::ERROR_NAMES | |
CardScheme::getDefaultOption | public | function | Returns the name of the default option. | Overrides Constraint::getDefaultOption | |
CardScheme::getRequiredOptions | public | function | Returns the name of the required options. | Overrides Constraint::getRequiredOptions | |
CardScheme::INSTAPAYMENT | public | constant | |||
CardScheme::INVALID_FORMAT_ERROR | public | constant | |||
CardScheme::JCB | public | constant | |||
CardScheme::LASER | public | constant | |||
CardScheme::MAESTRO | public | constant | |||
CardScheme::MASTERCARD | public | constant | |||
CardScheme::MIR | public | constant | |||
CardScheme::NOT_NUMERIC_ERROR | public | constant | |||
CardScheme::UATP | public | constant | |||
CardScheme::VISA | public | constant | |||
CardScheme::__construct | public | function | Overrides Constraint::__construct | ||
Constraint::$groups | public | property | The groups that the constraint belongs to. | ||
Constraint::$payload | public | property | Domain-specific data attached to a constraint. | ||
Constraint::addImplicitGroupName | public | function | Adds the given group if this constraint is in the Default group. | 2 | |
Constraint::CLASS_CONSTRAINT | public | constant | Marks a constraint that can be put onto classes. | ||
Constraint::DEFAULT_GROUP | public | constant | The name of the group given to all constraints with no explicit group. | ||
Constraint::getErrorName | public static | function | Returns the name of the given error code. | ||
Constraint::getTargets | public | function | Returns whether the constraint can be put onto classes, properties or both. |
8 | |
Constraint::normalizeOptions | protected | function | |||
Constraint::PROPERTY_CONSTRAINT | public | constant | Marks a constraint that can be put onto properties. | ||
Constraint::validatedBy | public | function | Returns the name of the class that validates this constraint. | 9 | |
Constraint::__get | public | function | Returns the value of a lazily initialized option. | 2 | |
Constraint::__isset | public | function | 1 | ||
Constraint::__set | public | function | Sets the value of a lazily initialized option. | 1 | |
Constraint::__sleep | public | function | Optimizes the serialized value to minimize storage space. |