reactive forms validation

19 views
Skip to first unread message

john.mb...@gmail.com

unread,
Mar 16, 2021, 6:53:14 AM3/16/21
to Angular and AngularJS discussion
Hi, 

So some of my matchingElementDifferential have min=1 and a max=1 
what I am doing below kind of only seems to work for min=1?!

if (matchingElementDifferential.min > 0 || matchingElementDifferential.max > 0) {
console.log('validatorsa: ',matchingElementDifferential.min);
console.log('validatorsb: ',matchingElementDifferential.max);
validators.push(
Validators.required,
Validators.requiredTrue,
Validators.minLength(matchingElementDifferential.min),
Validators.maxLength(matchingElementDifferential.max)
);
}
else if (matchingElementDifferential.min > 0) {
console.log('validatorsc: ',matchingElementDifferential.min);
validators.push(
Validators.required,
Validators.minLength(matchingElementDifferential.min)
);
}
else if (matchingElementDifferential.max) {
validators.push(
Validators.required,
Validators.maxLength(matchingElementDifferential.max)
);
}
Reply all
Reply to author
Forward
0 new messages