Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Validator.php

class Validator

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/TextUI/Configuration/Xml/Validator/Validator.php \PHPUnit\TextUI\XmlConfiguration\Validator
  2. 11.1.x vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php \JsonSchema\Validator

Rfc4122\Validator validates strings as UUIDs of the RFC 4122 variant

@psalm-immutable

Hierarchy

  • class \Ramsey\Uuid\Rfc4122\Validator implements \Ramsey\Uuid\Validator\ValidatorInterface

Expanded class hierarchy of Validator

6 string references to 'Validator'
ArgumentPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Provide a form to edit options for this plugin.
Constraint::validatedBy in vendor/symfony/validator/Constraint.php
Returns the name of the class that validates this constraint.
ExpressionSyntax::validatedBy in vendor/symfony/validator/Constraints/ExpressionSyntax.php
Returns the name of the class that validates this constraint.
ValidatorDataCollector::getName in vendor/symfony/validator/DataCollector/ValidatorDataCollector.php
Returns the name of the collector.
views.data_types.schema.yml in core/modules/views/config/schema/views.data_types.schema.yml
core/modules/views/config/schema/views.data_types.schema.yml

... See full list

File

vendor/ramsey/uuid/src/Rfc4122/Validator.php, line 28

Namespace

Ramsey\Uuid\Rfc4122
View source
final class Validator implements ValidatorInterface {
    private const VALID_PATTERN = '\\A[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-' . '[1-8][0-9A-Fa-f]{3}-[ABab89][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}\\z';
    
    /**
     * @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
     */
    public function getPattern() : string {
        return self::VALID_PATTERN;
    }
    public function validate(string $uuid) : bool {
        $uuid = str_replace([
            'urn:',
            'uuid:',
            'URN:',
            'UUID:',
            '{',
            '}',
        ], '', $uuid);
        $uuid = strtolower($uuid);
        return $uuid === Uuid::NIL || $uuid === Uuid::MAX || preg_match('/' . self::VALID_PATTERN . '/Dms', $uuid);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Validator::getPattern public function @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
Overrides ValidatorInterface::getPattern
Validator::validate public function Returns true if the provided string represents a UUID Overrides ValidatorInterface::validate
Validator::VALID_PATTERN private constant

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal