Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Created June 16, 2019 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/59dc66613fc5a0bccc7bf100aed2cbfc to your computer and use it in GitHub Desktop.
Save NetanelBasal/59dc66613fc5a0bccc7bf100aed2cbfc to your computer and use it in GitHub Desktop.
@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