custom validation issue on kendo
olayda opened this issue · 0 comments
I'm submitting a
[ ] Bug / Regression
[ ] Feature Request / Proposal
I'm using
NG Dynamic Forms Version: `X.Y.Z`
[ ] Basic UI
[ ] Bootstrap UI
[ ] Foundation UI
[ ] Ionic UI
[ x] Kendo UI
[ ] Material
[ ] NG Bootstrap
[ ] Prime NG
Description
hello, I am trying to create custom validation for my datepicker
new DynamicFormGroupModel({
id: "etaDetails",
legend: "Details",
group: [
new DynamicDatePickerModel({
id: "etaDate",
label: "ETA*",
format: "dd/MM/yyyy",
validators:{
required: null,
// myCustomValidator: null,
}
// ,errorMessages: {
// myCustomValidator: 'ETA must be within 3 months'
// },
}),
I implemented this to my module file too
providers: [ HIDDEN_MATCHER_PROVIDER,DISABLED_MATCHER_PROVIDER, REQUIRED_MATCHER_PROVIDER,
{provide: NG_VALIDATORS, useValue: myCustomValidator, multi: true}],
and my abstract file looks like this
import { AbstractControl, ValidationErrors } from "@angular/forms";
export function myCustomValidator(control: AbstractControl): ValidationErrors | null {
const hasError = control.value ? (control.value as string).startsWith("abc") : false;
return hasError ? {myCustomValidator: true} : null;
}
I get this error cannot read properties of undefined (reading 'invalid') at DynamicFormValidationService.showErrorMessages.
Could you please help be about what I am doing wrong. Thank you