Created
June 16, 2019 06:34
-
-
Save NetanelBasal/59dc66613fc5a0bccc7bf100aed2cbfc to your computer and use it in GitHub Desktop.
This file contains 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
@Component({ | |
providers: [ | |
{ | |
provide: NG_VALIDATORS, | |
useExisting: CaptchaComponent, | |
multi: true | |
} | |
] | |
}) | |
export class CaptchaComponent implements OnInit, ControlValueAccessor { | |
... | |
validate({ value }: FormControl) { | |
const isNotValid = this.answer !== Number(value); | |
return isNotValid && { | |
invalid: true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment