Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isInstanceOf(type: Function & (new (...args: any[]) => T)): Predicate { // tslint:disable-line:ban-types
return Predicate.to(`be an instance of ${ type.name }`, (value: T) =>
value instanceof type);
}
function looksLikeBase64Encoded(): Predicate {
const regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/;
return Predicate.to(`be an ISO-8601-compliant date`, (value: string) => regex.test(value));
}
function isSerialisedISO8601Date(): Predicate {
return Predicate.to(`be an ISO-8601-compliant date`, (value: string) =>
moment(value, moment.ISO_8601, true).isValid());
}