All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.app.shared.validators.duration.validator.ts Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
import { ValidatorFn, AbstractControl } from '@angular/forms';

export function durationValidator(): ValidatorFn {
    return (control: AbstractControl): { [key: string]: boolean } | null => {
        if (control.value && /(\d+(?:[.,]\d+)?)\s+(?:ms|s|sec|m|min|h|hour|hours|hours\(s\)|d|day|days|day\(s\))/.test(control.value)) {
            return null;
        }
        return { 'duration': false};
    };
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy