Skip to content

Commit e3b84a5

Browse files
authored
Merge pull request #1217 from murtukov/improve-docs
Fix typos and improve clarity in validation documentation
2 parents cd19c3e + 12ee906 commit e3b84a5

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

docs/validation/index.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
> _The validation feature was introduced in the version **0.13**_
1+
> _The validation feature was introduced in version **0.13**_
22
33
# Validation
44

@@ -8,7 +8,7 @@ to validate user input data. It currently supports only GraphQL schemas defined
88
### Contents:
99
- [Overview](#overview)
1010
- [How does it work?](#how-does-it-work)
11-
- [Applying of validation constraints](#applying-of-validation-constraints)
11+
- [Applying validation constraints](#applying-validation-constraints)
1212
- [Listing constraints directly](#listing-constraints-directly)
1313
- [object](#object)
1414
- [input-object](#input-object)
@@ -104,7 +104,7 @@ The configuration above checks, that:
104104
- the number of items in the collection is between 1 and 3
105105
- every item in the collection is a valid email address
106106
107-
The `birthdate` field is of type `input-object` and is marked as `cascade` so it's validation will happen according to the constraints declared in the `Birthdate` type:
107+
The `birthdate` field is of type `input-object` and is marked as `cascade`, so its validation will happen according to the constraints declared in the `Birthdate` type:
108108
- **day** is between 1 and 31
109109
- **month** is between 1 and 12
110110
- **year** is between 1900 and 2019
@@ -142,7 +142,7 @@ If you don't mark embedded types as `cascade`, they will stay arrays, which can
142142
following examples.
143143

144144
All object properties are created dynamically and then the validation constraints are applied to them. The resulting
145-
object composition will be then recursively validated, starting from the root object down to it's children.
145+
object composition will then be recursively validated, starting from the root object down to its children.
146146

147147
> **Note**:
148148
> Although it would have been possible to validate raw arguments, objects provide a better flexibility and more features.
@@ -274,9 +274,9 @@ The configuration above would produce an object composition as shown in the UML
274274
> Note: The argument `address` in the object `Mutation` wasn't converted into an object, as it doesn't have the key `cascade`, but it will still be validated against the `Collection` constraint as an array.
275275

276276

277-
## Applying of validation constraints
277+
## Applying validation constraints
278278

279-
If you are familiar with Symfony Validator Сomponent, then you might know that constraints can have different
279+
If you are familiar with the Symfony Validator Component, you might know that constraints can have different
280280
[targets](https://symfony.com/doc/current/validation.html#constraint-targets) (class members or entire classes). Since
281281
all input data is represented by objects during the validation, you can also declare member constraints as well as class
282282
constraints.
@@ -342,7 +342,7 @@ Mutation:
342342
email: String
343343
info: String
344344
```
345-
It's also possible to declare validation constraints to the entire _type_. This is useful if you don't want to repeat the configuration for each field or if you want to move the entire validation logic into a function:
345+
It's also possible to declare validation constraints for the entire _type_. This is useful if you don't want to repeat the configuration for each field or if you want to move the entire validation logic into a function:
346346
```yaml
347347
Mutation:
348348
type: object
@@ -439,13 +439,13 @@ If you already have classes (e.g. Doctrine entities) with validation constraints
439439
A `link` can have 4 different forms, each of which targets different parts of a class:
440440
- **property**: `<ClassName>::$<propertyName>` - the `$` symbol indicates a *single* class property.
441441
- **getters**: `<ClassName>::<propertyName>()` - the parentheses indicate *all* getters of the given property name.
442-
- **property and getters**: `<ClassName>::<propertyName>` - the absence of the `$` and parentheses indicates a single property and all it's getters.
442+
- **property and getters**: `<ClassName>::<propertyName>` - the absence of the `$` and parentheses indicates a single property and all its getters.
443443
- **class**: `<ClassName>` - the absence of a class member indicates an entire class.
444444

445445
for example:
446446
- **property**: `App\Entity\User::$username` - copies constraints of the property `$username` of the class `User`.
447447
- **getters**: `App\Entity\User::username()` - copies constraints of the getters `getUsername()`, `isUsername()` and `hasUsername()`.
448-
- **property and getters**: `App\Entity\User::username` - copies constraints of the property `$username` and it's getters `getUsername()`, `isUsername()` and `hasUsername()`.
448+
- **property and getters**: `App\Entity\User::username` - copies constraints of the property `$username` and its getters `getUsername()`, `isUsername()` and `hasUsername()`.
449449
- **class**: `App\Entity\User` - copies constraints applied to the entire class `User`.
450450

451451
> **Note**:
@@ -455,7 +455,7 @@ for example:
455455

456456
> **Note**:
457457
> Linked constraints which work in a context (e.g. Expression or Callback) will NOT copy the context of the linked
458-
>class, but instead will work in it's own. That means that the `this` variable won't point to the linked class
458+
>class, but instead will work in its own context. That means that the `this` variable won't point to the linked class
459459
>instance, but will point to an object of the class `ValidationNode` representing your input data. See the [How does it work?](#how-does-it-work) section for more details about internal work of the validation process.
460460

461461
#### Example:
@@ -509,22 +509,22 @@ Then you could link class members this way:
509509
```yaml
510510
Mutation:
511511
type: object
512-
config:
513-
fields:
514-
editPost:
515-
type: Post
516-
resolve: "@=mutation('edit_post', [args])"
517-
validation:
518-
link: App\Entity\Post # targeting the class
519-
args:
520-
title:
521-
type: String!
522-
validation:
523-
link: App\Entity\Post::title # property and getters
524-
text:
525-
type: String!
526-
validation:
527-
link: App\Entity\Post::$text # only property
512+
config:
513+
fields:
514+
editPost:
515+
type: Post
516+
resolve: "@=mutation('edit_post', [args])"
517+
validation:
518+
link: App\Entity\Post # targeting the class
519+
args:
520+
title:
521+
type: String!
522+
validation:
523+
link: App\Entity\Post::title # property and getters
524+
text:
525+
type: String!
526+
validation:
527+
link: App\Entity\Post::$text # only property
528528
```
529529
or use the short form (omitting the `link` key), which is equal to the config above:
530530
```yaml
@@ -594,20 +594,20 @@ type. The nesting can be any depth.
594594
```yaml
595595
Mutation:
596596
type: object
597-
config:
598-
fields:
599-
updateUser:
600-
type: Post
601-
resolve: "@=mutation('update_user', [args])"
602-
args:
603-
id:
604-
type: ID!
605-
address:
606-
type: AddressInput
607-
validation: cascade # delegate to AddressInput
608-
workPeriod:
609-
type: PeriodInput
610-
validation: cascade # delegate to PeriodInput
597+
config:
598+
fields:
599+
updateUser:
600+
type: Post
601+
resolve: "@=mutation('update_user', [args])"
602+
args:
603+
id:
604+
type: ID!
605+
address:
606+
type: AddressInput
607+
validation: cascade # delegate to AddressInput
608+
workPeriod:
609+
type: PeriodInput
610+
validation: cascade # delegate to PeriodInput
611611
612612
AddressInput:
613613
type: input-object
@@ -1068,7 +1068,7 @@ To translate into other languages just create additional translation resource w
10681068

10691069
## Using built-in expression functions
10701070

1071-
This bundle comes with built-in [ExpressionLanguage](#https://symfony.com/doc/current/components/expression_language.html)
1071+
This bundle comes with a built-in [ExpressionLanguage](https://symfony.com/doc/current/components/expression_language.html)
10721072
instance and pre-registered [expression functions and variables](https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/expression-language.md).
10731073
By default the [`Expression`](https://symfony.com/doc/current/reference/constraints/Expression.html)
10741074
constraint in your project has no access to these functions and variables, because it uses the default instance of the

0 commit comments

Comments
 (0)