"angular from date to date validation" Code Answer's
You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "angular from date to date validation" answered properly. Developers are finding an appropriate answer about angular from date to date validation related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like angular from date to date validation. Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on angular from date to date validation.
angular from date to date validation
export class CustomeDateValidators {
static fromToDate(fromDateField: string, toDateField: string, errorName: string = 'fromToDate'): ValidatorFn {
return (formGroup: AbstractControl): { [key: string]: boolean } | null => {
const fromDate = formGroup.get(fromDateField).value;
const toDate = formGroup.get(toDateField).value;
// Ausing the fromDate and toDate are numbers. In not convert them first after null check
if ((fromDate !== null && toDate !== null) && fromDate > toDate) {
return {[errorName]: true};
}
return null;
};
}
}
/*--- implementations ---*/
this.form = this.fb.group({
fromDate: null,
toDate: null,
}, { validator: [
//Default error with this validator: {fromToDate: true}
CustomeDateValidators.fromToDate('fromDate', 'toDate')
// For custome error name like: {customeErrorName: true}, pass third optional parameter with custome name
// CustomeDateValidators.fromToDate('fromDate', 'toDate', 'customeErrorName')
]});
Source: stackoverflow.com
All those coders who are working on the TypeScript based application and are stuck on angular from date to date validation can get a collection of related answers to their query. Programmers need to enter their query on angular from date to date validation related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about angular from date to date validation for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of angular from date to date validation while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "angular from date to date validation". Visit this developer's friendly online web community, CodeProZone, and get your queries like angular from date to date validation resolved professionally and stay updated to the latest TypeScript updates.