How to use the tiny-types.Predicate.to function in tiny-types

To help you get started, weā€™ve selected a few tiny-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jan-molak / serenity-js / packages / core / src / model / Timestamp.ts View on Github external
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);
}
github jan-molak / serenity-js / packages / core / src / model / Photo.ts View on Github external
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));
}
github jan-molak / serenity-js / packages / core / src / model / Timestamp.ts View on Github external
function isSerialisedISO8601Date(): Predicate {
    return Predicate.to(`be an ISO-8601-compliant date`, (value: string) =>
        moment(value, moment.ISO_8601, true).isValid());
}