Im currently working on developing a unique custom validator for the datepicker
feature within a reactive form group.
Within my code file, specifically the .ts file:
form: FormGroup;
constructor(
private fb: FormBuilder,
private validatorSrv: CustomValidatorService,
) {}
createForm(): void {
this.form = this.fb.group({
trans_date: [null, [Validators.required, this.validatorSrv.validDate]]
});
}
Now, focusing on the CustomValidatorService
class:
validDate(c: AbstractControl): any {
// It always return 'Mon Jan 01 2001 00:00:00 GMT+0800 (Taipei Standard Time)'
// When value is 1
// And 'Sat Dec 01 2001 00:00:00 GMT+0800 (Taipei Standard Time)'
// When value is 12
console.log(c.value);
}
In the scenario mentioned above, it consistently outputs a JavaScript datetime object.
Is there a way to extract the exact input value from the custom validator's AbstractControl?