Documentation

Validator
in package
implements ValidatorInterface

Rfc4122\Validator validates strings as UUIDs of the RFC 4122 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}-' . '[1-5]{1}[0-9A-Fa-f]{3}-[ABab89]{1}[0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\\z'
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

private mixed VALID_PATTERN = '\\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-' . '[1-5]{1}[0-9A-Fa-f]{3}-[ABab89]{1}[0-9A-Fa-f]{3}-[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