Skip to content

Commit 84f4524

Browse files
wouterjweaverryan
authored andcommitted
Applied comments by @cordoval
1 parent c024ef2 commit 84f4524

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

components/validator/introduction.rst

+9-8
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Usage
2020
-----
2121

2222
The Validator component allows you to use very advanced validation rules, but
23-
it is also really easy to do very minor validation. For instance, if you want
24-
to validate a string against a specific length, the only code you need is::
23+
it is also really easy to do easy validation tasks. For instance, if you want
24+
to validate a string is at least 10 character long, the only code you need is::
2525

2626
use Symfony\Component\Validator\Validation;
2727
use Symfony\Component\Validator\Constraints\Length;
@@ -31,7 +31,7 @@ to validate a string against a specific length, the only code you need is::
3131
$violations = $validator->validateValue('Bernhard', new Length(array('min' => 10)));
3232

3333
if (0 !== count($violations)) {
34-
// there are errors, let's show them
34+
// there are errors, now you can show them
3535
foreach ($violations as $violation) {
3636
echo $violation->getMessage().'<br>';
3737
}
@@ -42,19 +42,20 @@ Retrieving a Validator Instance
4242

4343
The :class:`Symfony\\Component\\Validator\\Validator` class is the main access
4444
point of the Validator component. To create a new instance of this class, it
45-
is recomment to use the :class:`Symfony\\Component\Validator\Validation`
45+
is recommend to use the :class:`Symfony\\Component\Validator\Validation`
4646
class.
4747

48-
You can get the ``Validator`` with the default configuration by calling
48+
You can get a very basic ``Validator`` by calling
4949
:method:`Validation::createValidator() <Symfony\\Component\\Validator\\Validation::createValidator>`::
5050

5151
use Symfony\Component\Validator\Validation;
5252

5353
$validator = Validation::createValidator();
5454

55-
However, a lot of things can be customized. To configure the ``Validator``
56-
class, you can use the :class:`Symfony\\Component\\Validator\\ValidatorBuilder`.
57-
This class can be retrieved by using the
55+
The created validator can be used to validate strings, array, numbers, but it
56+
can't validate classes. To be able to do that, you have to configure the ``Validator``
57+
class. To do that, you can use the :class:`Symfony\\Component\\Validator\\ValidatorBuilder`.
58+
This class can be retrieved by using the
5859
:method:`Validation::createValidatorBuilder() <Symfony\\Component\\Validator\\Validation::createValidatorBuilder>`
5960
method::
6061

components/validator/resources.rst

+17-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Loading Resources
77
The Validator uses metadata to validate a value. This metadata defines how a
88
class, array or any other value should be validated. When validating a class,
99
each class contains its own specific metadata. When validating another value,
10-
the metadata to passed to the validate methods.
10+
the metadata must be passed to the validate methods.
1111

1212
Class metadata should be defined somewhere in a configuration file, or in the
1313
class itself. The ``Validator`` needs to be able to retrieve this metadata
@@ -20,7 +20,7 @@ from the file or class. To do that, it uses a set of loaders.
2020
The StaticMethodLoader
2121
----------------------
2222

23-
The easiest loader is the
23+
The most basic loader is the
2424
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\StaticMethodLoader`.
2525
This loader will call a static method of the class in order to get the
2626
metadata for that class. The name of the method is configured using the
@@ -34,7 +34,7 @@ method of the Validator builder::
3434
->getValidator();
3535

3636
Now, the retrieved ``Validator`` tries to find the ``loadValidatorMetadata()``
37-
method of the validated class to load its metadata.
37+
method of the class to validate to load its metadata.
3838

3939
.. tip::
4040

@@ -70,8 +70,9 @@ The AnnotationLoader
7070

7171
At last, the component provides an
7272
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AnnotationLoader`.
73-
This loader will parse the annotations of a class. Annotations are placed in
74-
PHPdoc comments (`/** ... */`) and start with an ``@``. For instance::
73+
This loader uses an annotation reader to parse the annotations of a class.
74+
Annotations are placed in doc block comments (`/** ... */`) and start with an
75+
``@``. For instance::
7576

7677
// ...
7778

@@ -97,7 +98,7 @@ To disable the annotation loader after it was enabled, call
9798
.. note::
9899

99100
In order to use the annotation loader, you should have installed the
100-
``doctrine/annotations`` and ``doctrine/cache`` packages of Packagist.
101+
``doctrine/annotations`` and ``doctrine/cache`` packages from Packagist.
101102

102103
Using Multiple Loaders
103104
----------------------
@@ -121,9 +122,9 @@ multiple mappings::
121122
Caching
122123
-------
123124

124-
Using many loaders to load metadata from different places is very easy for the
125-
developer, but it can easily slow down your application since each file needs
126-
to be parsed, validated and converted to a
125+
Using many loaders to load metadata from different places is very easy when
126+
creating the metadata, but it can easily slow down your application since each
127+
file needs to be parsed, validated and converted to a
127128
:class:`Symfony\\Component\\Validator\\Mapping\\ClassMetadata` instance. To
128129
solve this problems, you can configure a cacher which will be used to cache
129130
the ``ClassMetadata`` after it was loaded.
@@ -135,10 +136,11 @@ implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface
135136

136137
.. note::
137138

138-
The loader already use a singleton load mechanism. That means that they
139-
will only load and parse a file once and put that in a property, which
140-
will be used on the next time. However, the Validator still needs to
141-
merge all metadata of one class from every loader when it is requested.
139+
The loaders already use a singleton load mechanism. That means that the
140+
loaders will only load and parse a file once and put that in a property,
141+
which will then be used the next time it is asked for metadata. However,
142+
the Validator still needs to merge all metadata of one class from every
143+
loader when it is requested.
142144

143145
To set a cacher, call the
144146
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataCache` of
@@ -176,5 +178,5 @@ this custom implementation using
176178
.. caution::
177179

178180
Since you are using a custom metadata factory, you can't configure loaders
179-
and cachers using the helper methods anymore. You now have to inject them
180-
into your custom metadata factory yourself.
181+
and cachers using the ``add*Mapping()`` methods anymore. You now have to
182+
inject them into your custom metadata factory yourself.

0 commit comments

Comments
 (0)