From 49e900d6fcd43850d96d9c7637f356c29334adda Mon Sep 17 00:00:00 2001 From: Tomasz Kula Date: Wed, 6 Jun 2018 10:09:52 +0200 Subject: [PATCH] docs(aio): fix issues suggested by Kara (#23743) PR Close #23743 --- .../src/app/shared/identity-revealed.directive.ts | 2 +- aio/content/guide/form-validation.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aio/content/examples/form-validation/src/app/shared/identity-revealed.directive.ts b/aio/content/examples/form-validation/src/app/shared/identity-revealed.directive.ts index a5ae08d2ae..b5dbd05c15 100644 --- a/aio/content/examples/form-validation/src/app/shared/identity-revealed.directive.ts +++ b/aio/content/examples/form-validation/src/app/shared/identity-revealed.directive.ts @@ -8,7 +8,7 @@ export const identityRevealedValidator: ValidatorFn = (control: FormGroup): Vali const name = control.get('name'); const alterEgo = control.get('alterEgo'); - return name && alterEgo && name.value !== alterEgo.value ? null : { 'identityRevealed': true }; + return name && alterEgo && name.value === alterEgo.value ? { 'identityRevealed': true } : null; }; // #enddocregion cross-validation-validator diff --git a/aio/content/guide/form-validation.md b/aio/content/guide/form-validation.md index 91c8991b18..3c27230cf8 100644 --- a/aio/content/guide/form-validation.md +++ b/aio/content/guide/form-validation.md @@ -231,9 +231,9 @@ const heroForm = new FormGroup({ }); ``` -Notice that the name and alterEgo are sibling controls. To evaluate both controls in a single custom validator, we should perform the validation in a common ancestor control: the FormGroup. That way, we can query the FormGroup for the child controls which will allow us to compare their values. +Notice that the name and alterEgo are sibling controls. To evaluate both controls in a single custom validator, we should perform the validation in a common ancestor control: the `FormGroup`. That way, we can query the `FormGroup` for the child controls which will allow us to compare their values. -To add a validator to the FormGroup, pass the new validator in as the second argument on creation. +To add a validator to the `FormGroup`, pass the new validator in as the second argument on creation. ```javascript const heroForm = new FormGroup({ @@ -248,7 +248,7 @@ The validator code is as follows: -Identity validator implements the `ValidatorFn` interface. It takes an Angular control object as an argument and returns either null if the form is valid, or `ValidationErrors` otherwise. +The identity validator implements the `ValidatorFn` interface. It takes an Angular control object as an argument and returns either null if the form is valid, or `ValidationErrors` otherwise. First we retrieve the child controls by calling the `FormGroup`'s [get](api/forms/AbstractControl#get) method. Then we simply compare the values of the `name` and `alterEgo` controls.