Socket
Socket
Sign inDemoInstall

@6river/reason-guard

Package Overview
Dependencies
Maintainers
4
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@6river/reason-guard - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

1

dist/src/restrictingGuards.d.ts

@@ -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

2

package.json

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc