This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html"> | |
<source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source> | |
<target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target> | |
</trans-unit> | |
<trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html"> | |
<source>{VAR_SELECT, select, male {male} female {female} other {other} }</source> | |
<target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target> | |
</trans-unit> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngOnInit() { | |
this.myForm = this.fb.group({ | |
name: ['', Validators.required], | |
email: [ | |
'', | |
[Validators.required, Validators.email], | |
ValidateEmailNotTaken.createValidator(this.signupService), | |
{updateOn: 'blur'} | |
] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form [formGroup]="myForm"> | |
<input type="text" formControlName="name"> | |
<input type="email" formControlName="email"> | |
<!-- Other related errors go here--> | |
<div *ngIf="myForm.get('email').errors && myForm.get('email').errors.emailUnavailable"> | |
This email is already taken. | |
</div> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngOnInit() { | |
this.myForm = this.fb.group({ | |
name: ['', Validators.required], | |
email: [ | |
'', | |
[Validators.required, Validators.email], | |
ValidateEmailNotTaken.createValidator(this.signupService) | |
] | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor(private fb: FormBuilder, | |
private loanAmountValidatorService: LoanAmountValidatorService) { } | |
ngOnInit() { | |
this.newsletterForm = this.fb.group({ | |
email: ['', [Validators.required, Validators.email]], | |
}, {validators: this.loanAmountValidatorService.loanAmountValidator}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive } from '@angular/core'; | |
import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator } from '@angular/forms'; | |
import { LoanAmountValidatorService } from './loan-amount-validator.service'; | |
@Directive({ | |
selector: '[razrooLoanAmount]', | |
providers: [{ provide: NG_VALIDATORS, useExisting: LoanAmountDirective, multi: true }] | |
}) | |
export class LoanAmountDirective implements Validator { | |
constructor(private loanAmountValidatorService: LoanAmountValidatorService) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { FormGroup, ValidationErrors, ValidatorFn } from '@angular/forms'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class LoanAmountValidatorService { | |
constructor() { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, forwardRef } from '@angular/core'; | |
import { AbstractControl, NG_VALIDATORS, Validator } from '@angular/forms'; | |
import { number } from './validator'; | |
const NUMBER_VALIDATOR: any = { | |
provide: NG_VALIDATORS, | |
useExisting: forwardRef(() => NumberDirective), | |
multi: true | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AbstractControl, Validators, ValidatorFn } from '@angular/forms'; | |
function isPresent(obj: any): boolean { | |
return obj !== undefined && obj !== null; | |
} | |
export const number: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => { | |
if (isPresent(Validators.required(control))) return null; | |
let v: string = control.value; |