-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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` | ||
class. | ||
|
||
You can get the ``Validator`` with the default configuration by calling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better than ... is to add a simple example There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woah! recommended
There was a problem hiding this comment.
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 ...