Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Validator] Add documentation for ULID validator#14350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
OskarStark merged 1 commit intosymfony:5.xfromlaurent35240:ulid-validator
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletionsreference/constraints/Ulid.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
ULID
====

.. versionadded:: 5.2

The ULID validator was introduced in Symfony 5.2.

Validates that a value is a valid `Universally Unique Lexicographically Sortable Identifier (ULID)`_.

========== ===================================================================
Applies to :ref:`property or method <validation-property-target>`
Options - `groups`_
- `message`_
- `normalizer`_
- `payload`_
Class :class:`Symfony\\Component\\Validator\\Constraints\\Ulid`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\UlidValidator`
========== ===================================================================

Basic Usage
-----------

.. configuration-block::

.. code-block:: php-annotations

// src/Entity/File.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;

class File
{
/**
* @Assert\Ulid
*/
protected $identifier;
}

.. code-block:: yaml

# config/validator/validation.yaml
App\Entity\File:
properties:
identifier:
- Ulid: ~

.. code-block:: xml

<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

<class name="App\Entity\File">
<property name="identifier">
<constraint name="Ulid"/>
</property>
</class>
</constraint-mapping>

.. code-block:: php

// src/Entity/File.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;

class File
{
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('identifier', new Assert\Ulid());
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

.. include:: /reference/constraints/_groups-option.rst.inc

``message``
~~~~~~~~~~~

**type**: ``string`` **default**: ``This is not a valid ULID.``

This message is shown if the string is not a valid ULID.

You can use the following parameters in this message:

=============== ==============================================================
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. include:: /reference/constraints/_normalizer-option.rst.inc

.. include:: /reference/constraints/_payload-option.rst.inc


.. _`Universally Unique Lexicographically Sortable Identifier (ULID)`: https://github.com/ulid/spec
1 change: 1 addition & 0 deletionsreference/constraints/map.rst.inc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@ String Constraints
* :doc:`Ip </reference/constraints/Ip>`
* :doc:`Json </reference/constraints/Json>`
* :doc:`Uuid </reference/constraints/Uuid>`
* :doc:`Ulid </reference/constraints/Ulid>`
* :doc:`UserPassword </reference/constraints/UserPassword>`
* :doc:`NotCompromisedPassword </reference/constraints/NotCompromisedPassword>`

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp