ts-cast
Version:
Runtime typechecking
13 lines (12 loc) • 650 B
JavaScript
import { withName } from '../helpers/names';
export const nonEmpty = withName((value) => value.length > 0, 'non empty');
export const longerThen = (len) => withName((value) => value.length > len, `longer then ${len}`);
export const shorterThen = (len) => withName((value) => value.length < len, `shorter then ${len}`);
export const notLongerThen = (len) => withName((value) => value.length <= len, `not longer then ${len}`);
export const notShorterThen = (len) => withName((value) => value.length >= len, `not shorter then ${len}`);
export const length = {
gt: longerThen,
gte: notShorterThen,
lt: shorterThen,
lte: notLongerThen,
};