Documentation

GenericValidator
in package
implements ValidatorInterface

GenericValidator validates strings as UUIDs of any variant

Tags
psalm-immutable

Interfaces, Classes, Traits and Enums

ValidatorInterface
A validator validates a string as a proper UUID

Table of Contents

VALID_PATTERN  = '\\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\z'
Regular expression pattern for matching a UUID of any variant.
getPattern()  : string
Returns the regular expression pattern used by this validator
validate()  : bool
Returns true if the provided string represents a UUID

Constants

VALID_PATTERN

Regular expression pattern for matching a UUID of any variant.

private mixed VALID_PATTERN = '\\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\z'

Methods

getPattern()

Returns the regular expression pattern used by this validator

public getPattern() : string
Tags
psalm-return

non-empty-string

psalm-suppress

MoreSpecificReturnType we know that the retrieved string is never empty

psalm-suppress

LessSpecificReturnStatement we know that the retrieved string is never empty

Return values
string

The regular expression pattern this validator uses

validate()

Returns true if the provided string represents a UUID

public validate(string $uuid) : bool
Parameters
$uuid : string

The string to validate as a UUID

Return values
bool

True if the string is a valid UUID, false otherwise

Search results