@6river/reason-guard
Advanced tools
Comparing version 5.1.0 to 5.1.1
@@ -56,2 +56,3 @@ import { ReasonGuard } from './ReasonGuard'; | ||
export declare function isLiteral<T extends Literable, U extends T>(keys: ReadonlyArray<U>, literableGuard?: ReasonGuard<unknown, Literable>): ReasonGuard<unknown, ArrayLiteralCheck<T, typeof keys>>; | ||
export declare const isNonEmptyString: import("./NegatableGuard").NegatableGuard<unknown, string, unknown>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isLiteral = exports.isLiterable = exports.isStrictEqual = exports.numberIsSafeInteger = exports.integralInterval = exports.interval = exports.numberIsGreaterThanOrEqual = exports.numberIsLessThanOrEqual = exports.numberIsAtLeast = exports.numberIsAtMost = exports.numberIs = exports.numberIsGreaterThan = exports.numberIsLessThan = exports.numberIsFinite = exports.numberIsInteger = exports.isUUID = exports.isUUIDString = exports.isDateOrDateString = void 0; | ||
exports.isNonEmptyString = exports.isLiteral = exports.isLiterable = exports.isStrictEqual = exports.numberIsSafeInteger = exports.integralInterval = exports.interval = exports.numberIsGreaterThanOrEqual = exports.numberIsLessThanOrEqual = exports.numberIsAtLeast = exports.numberIsAtMost = exports.numberIs = exports.numberIsGreaterThan = exports.numberIsLessThan = exports.numberIsFinite = exports.numberIsInteger = exports.isUUID = exports.isUUIDString = exports.isDateOrDateString = void 0; | ||
const Checker_1 = require("./Checker"); | ||
@@ -141,2 +141,9 @@ const Combinators_1 = require("./Combinators"); | ||
exports.isLiteral = isLiteral; | ||
const isNonEmptyStringChecker = (0, Checker_1.checkerToGuard)((input) => { | ||
if (input.length === 0) { | ||
return (0, ReasonGuard_1.errorLike)('String is has length of 0'); | ||
} | ||
return `${input} is non-empty string`; | ||
}); | ||
exports.isNonEmptyString = (0, Combinators_1.thenGuard)(primitiveGuards_1.isString, isNonEmptyStringChecker); | ||
//# sourceMappingURL=restrictingGuards.js.map |
@@ -274,3 +274,22 @@ "use strict"; | ||
}); | ||
context('isNonEmptyString', function () { | ||
const guard = restricting.isNonEmptyString; | ||
it('guards for populated strings', function () { | ||
(0, assertGuards_1.assertGuards)(true)(guard, 'foo'); | ||
(0, assertGuards_1.assertGuards)(true)(guard, 'bar'); | ||
(0, assertGuards_1.assertGuards)(true)(guard, ' '); | ||
}); | ||
it('guards against empty strings', function () { | ||
(0, assertGuards_1.assertGuards)(false)(guard, ''); | ||
}); | ||
it('guards against non-strings', function () { | ||
(0, assertGuards_1.assertGuards)(false)(guard, false); | ||
(0, assertGuards_1.assertGuards)(false)(guard, true); | ||
(0, assertGuards_1.assertGuards)(false)(guard, 1); | ||
(0, assertGuards_1.assertGuards)(false)(guard, 0); | ||
(0, assertGuards_1.assertGuards)(false)(guard, Number.NaN); | ||
(0, assertGuards_1.assertGuards)(false)(guard, {}); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=restrictingGuards.spec.js.map |
@@ -68,3 +68,3 @@ { | ||
}, | ||
"version": "5.1.0" | ||
"version": "5.1.1" | ||
} |
@@ -187,1 +187,10 @@ import { checkerToGuard } from './Checker'; | ||
} | ||
const isNonEmptyStringChecker = checkerToGuard<string, string>((input: string) => { | ||
if (input.length === 0) { | ||
return errorLike('String is has length of 0'); | ||
} | ||
return `${input} is non-empty string`; | ||
}); | ||
export const isNonEmptyString = thenGuard(isString, isNonEmptyStringChecker); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
262881
3288