class MacAddress
Validates that a value is a valid MAC address.
@author Ninos Ego <me@ninosego.de>
Hierarchy
- class \Symfony\Component\Validator\Constraint
- class \Symfony\Component\Validator\Constraints\MacAddress extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of MacAddress
File
-
vendor/
symfony/ validator/ Constraints/ MacAddress.php, line 23
Namespace
Symfony\Component\Validator\ConstraintsView source
class MacAddress extends Constraint {
public const ALL = 'all';
public const ALL_NO_BROADCAST = 'all_no_broadcast';
public const LOCAL_ALL = 'local_all';
public const LOCAL_NO_BROADCAST = 'local_no_broadcast';
public const LOCAL_UNICAST = 'local_unicast';
public const LOCAL_MULTICAST = 'local_multicast';
public const LOCAL_MULTICAST_NO_BROADCAST = 'local_multicast_no_broadcast';
public const UNIVERSAL_ALL = 'universal_all';
public const UNIVERSAL_UNICAST = 'universal_unicast';
public const UNIVERSAL_MULTICAST = 'universal_multicast';
public const UNICAST_ALL = 'unicast_all';
public const MULTICAST_ALL = 'multicast_all';
public const MULTICAST_NO_BROADCAST = 'multicast_no_broadcast';
public const BROADCAST = 'broadcast';
public const INVALID_MAC_ERROR = 'a183fbff-6968-43b4-82a2-cc5cf7150036';
private const TYPES = [
self::ALL,
self::ALL_NO_BROADCAST,
self::LOCAL_ALL,
self::LOCAL_NO_BROADCAST,
self::LOCAL_UNICAST,
self::LOCAL_MULTICAST,
self::LOCAL_MULTICAST_NO_BROADCAST,
self::UNIVERSAL_ALL,
self::UNIVERSAL_UNICAST,
self::UNIVERSAL_MULTICAST,
self::UNICAST_ALL,
self::MULTICAST_ALL,
self::MULTICAST_NO_BROADCAST,
self::BROADCAST,
];
protected const ERROR_NAMES = [
self::INVALID_MAC_ERROR => 'INVALID_MAC_ERROR',
];
public ?\Closure $normalizer;
/**
* @param self::ALL*|self::LOCAL_*|self::UNIVERSAL_*|self::UNICAST_*|self::MULTICAST_*|self::BROADCAST $type A mac address type to validate (defaults to {@see self::ALL})
*/
public function __construct(string $message = 'This value is not a valid MAC address.', string $type = self::ALL, ?callable $normalizer = null, ?array $groups = null, mixed $payload = null) {
parent::__construct(null, $groups, $payload);
if (!\in_array($this->type, self::TYPES, true)) {
throw new ConstraintDefinitionException(\sprintf('The option "type" must be one of "%s".', implode('", "', self::TYPES)));
}
$this->normalizer = null !== $normalizer ? $normalizer(...) : null;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
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::getDefaultOption | public | function | Returns the name of the default option. | 28 | |
Constraint::getErrorName | public static | function | Returns the name of the given error code. | ||
Constraint::getRequiredOptions | public | function | Returns the name of the required options. | 22 | |
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. | ||
MacAddress::$normalizer | public | property | |||
MacAddress::ALL | public | constant | |||
MacAddress::ALL_NO_BROADCAST | public | constant | |||
MacAddress::BROADCAST | public | constant | |||
MacAddress::ERROR_NAMES | protected | constant | Maps error codes to the names of their constants. | Overrides Constraint::ERROR_NAMES | |
MacAddress::INVALID_MAC_ERROR | public | constant | |||
MacAddress::LOCAL_ALL | public | constant | |||
MacAddress::LOCAL_MULTICAST | public | constant | |||
MacAddress::LOCAL_MULTICAST_NO_BROADCAST | public | constant | |||
MacAddress::LOCAL_NO_BROADCAST | public | constant | |||
MacAddress::LOCAL_UNICAST | public | constant | |||
MacAddress::MULTICAST_ALL | public | constant | |||
MacAddress::MULTICAST_NO_BROADCAST | public | constant | |||
MacAddress::TYPES | private | constant | |||
MacAddress::UNICAST_ALL | public | constant | |||
MacAddress::UNIVERSAL_ALL | public | constant | |||
MacAddress::UNIVERSAL_MULTICAST | public | constant | |||
MacAddress::UNIVERSAL_UNICAST | public | constant | |||
MacAddress::__construct | public | function | Overrides Constraint::__construct |