Skip to content

[WIP] Documenting the Validator component #3710

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added small configuration section
  • Loading branch information
wouterj committed Mar 23, 2014
commit 609774b1fe2d5f53a62e35bbe3a141af0a81edcc
33 changes: 32 additions & 1 deletion components/validator/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,40 @@ to validate a string against a specific length, the only code you need is::
}
}

Retrieving a Validator Instance
-------------------------------

The :class:`Symfony\\Component\\Validator\\Validator` class is the main access
point of the Validator component. To create a new instance of this class, it
is recomment to use the :class:`Symfony\\Component\Validator\Validation`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah! recommended

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just of this class, just use the ...

class.

You can get the ``Validator`` with the default configuration by calling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are not showing right after the default configuration then we should omit this and basically say a default validator instance rather

:method:`Validation::createValidator() <Symfony\\Component\\Validator\\Validation::createValidator>`::

use Symfony\Component\Validator\Validation;

$validator = Validation::createValidator();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please provide a tip saying how it is done in symfony or maybe the service factory is shared but each time it creates a validator or how it is done, would be a good complement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe let's also mention what the deps that configure a validator are:

    public function __construct(
        MetadataFactoryInterface $metadataFactory,
        ConstraintValidatorFactoryInterface $validatorFactory,
        TranslatorInterface $translator,
        $translationDomain = 'validators',
        array $objectInitializers = array()
    )


However, a lot of things can be customized. To configure the ``Validator``
class, you can use the :class:`Symfony\\Component\\Validator\\ValidatorBuilder`.
This class can be retrieved by using the
:method:`Validation::createValidatorBuilder() <Symfony\\Component\\Validator\\Validation::createValidatorBuilder>`
method::

use Symfony\Component\Validator\Validation;

$validator = Validation::createValidatorBuilder()
// ... build a custom instance of the Validator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better than ... is to add a simple example

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you don't know what it does, I don't think it's valuable at this point.

->getValidator();

What things you can configure will be documented in the following sections.

Sections
--------

* :doc:`/components/validator/configuration`
* :doc:`/components/validator/loading_resources`
* :doc:`/components/validator/defining_metadata`
* :doc:`/components/validator/validating_values`

.. _`JSR-303 Bean Validation specification`: http://jcp.org/en/jsr/detail?id=303
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy