@seges/angular-validators
Version:
TypeScript 1.8.10
23 lines (18 loc) • 587 B
text/typescript
import { IValidator } from "../IValidator";
export class Time24HourValidator implements IValidator<void> {
private regex: RegExp;
constructor() {
this.regex = new RegExp("^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$");
}
/**
* Validate input as 24 hour time format (HH:mm)
* If value is a valid 24 hour time format, return true. Otherwise return false.
* @param: Time value to test
*/
isValid(value: string): boolean {
if (!value) {
return false;
}
return this.regex.test(value);
}
}