n4s 4.1.9-dev-c786f7 → 4.1.9-dev-9b46fb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var n4s = require('n4s');
4
3
  var vestUtils = require('vest-utils');
4
+ var n4s = require('n4s');
5
5
 
6
6
  function ruleReturn(pass, message) {
7
7
  var output = { pass: pass };
@@ -1 +1 @@
1
- "use strict";var n=require("n4s"),t=require("vest-utils");function r(n,t){return n={pass:n},t&&(n.message=t),n}function u(n){return t.defaultTo(n,r(!0))}function e(n,t){try{return n.run(t)}catch(n){return r(!1)}}module.exports=function(){function r(r){return n.ctx.run({value:r},(function(){return u(t.mapFirst(s,(function(n,t){t(!(n=e(n,r)).pass,n)})))}))}for(var s=[],i=0;i<arguments.length;i++)s[i]=arguments[i];return t.assign((function(n){n=r(n),t.invariant(n.pass,t.StringObject(n.message))}),{run:r,test:function(n){return r(n).pass}})};
1
+ "use strict";var n=require("vest-utils"),t=require("n4s");function r(n,t){return n={pass:n},t&&(n.message=t),n}function u(t){return n.defaultTo(t,r(!0))}function e(n,t){try{return n.run(t)}catch(n){return r(!1)}}module.exports=function(){function r(r){return t.ctx.run({value:r},(function(){return u(n.mapFirst(s,(function(n,t){t(!(n=e(n,r)).pass,n)})))}))}for(var s=[],i=0;i<arguments.length;i++)s[i]=arguments[i];return n.assign((function(t){t=r(t),n.invariant(t.pass,n.StringObject(t.message))}),{run:r,test:function(n){return r(n).pass}})};
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var n4s = require('n4s');
4
3
  var vestUtils = require('vest-utils');
4
+ var n4s = require('n4s');
5
5
 
6
6
  function ruleReturn(pass, message) {
7
7
  var output = { pass: pass };
@@ -1 +1 @@
1
- "use strict";var n=require("n4s"),r=require("vest-utils");function t(n,r){return n={pass:n},r&&(n.message=r),n}function e(){return t(!1)}function u(n){return r.defaultTo(n,e())}function f(n){return r.defaultTo(n,t(!0))}function o(n,r){try{return n.run(r)}catch(n){return e()}}function i(n,r){return n===r}r.bindNot(i);n.enforce.extend({allOf:function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return f(r.mapFirst(t,(function(r,t){t(!(r=o(r,n)).pass,r)})))},anyOf:function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return u(r.mapFirst(t,(function(r,t){t((r=o(r,n)).pass,r)})))},noneOf:function(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return f(r.mapFirst(t,(function(r,t){t((r=o(r,n)).pass,e())})))},oneOf:function(n){for(var e=[],u=1;u<arguments.length;u++)e[u-1]=arguments[u];var f=0;return e.some((function(t){if(o(t,n).pass&&f++,r.greaterThan(f,1))return!1})),t(i(f,1))}});
1
+ "use strict";var n=require("vest-utils"),r=require("n4s");function t(n,r){return n={pass:n},r&&(n.message=r),n}function e(){return t(!1)}function u(r){return n.defaultTo(r,e())}function f(r){return n.defaultTo(r,t(!0))}function o(n,r){try{return n.run(r)}catch(n){return e()}}function i(n,r){return n===r}n.bindNot(i);r.enforce.extend({allOf:function(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return f(n.mapFirst(t,(function(n,t){t(!(n=o(n,r)).pass,n)})))},anyOf:function(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return u(n.mapFirst(t,(function(n,t){t((n=o(n,r)).pass,n)})))},noneOf:function(r){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return f(n.mapFirst(t,(function(n,t){t((n=o(n,r)).pass,e())})))},oneOf:function(r){for(var e=[],u=1;u<arguments.length;u++)e[u-1]=arguments[u];var f=0;return e.some((function(t){if(o(t,r).pass&&f++,n.greaterThan(f,1))return!1})),t(i(f,1))}});
@@ -333,30 +333,47 @@ function validateResult(result) {
333
333
 
334
334
  function enforceEager(value) {
335
335
  var target = {};
336
+ // This condition is for when we don't have proxy support (ES5).
337
+ // In this case, we need to manually assign the rules to the target object on runtime.
338
+ // The follow up proxy block is used in case we do have proxy support, and we can assign each rule upon invocation.
336
339
  if (!isProxySupported()) {
340
+ // We iterate over each of the rules, and add them to the target object being return by enforce
337
341
  eachEnforceRule(function (ruleName, ruleFn) {
342
+ // We then wrap the rule with `genRuleCall` that adds the base enforce behavior
338
343
  target[ruleName] = genRuleCall(target, ruleFn, ruleName);
339
344
  });
340
345
  return target;
341
346
  }
347
+ // We create a proxy intercepting access to the target object (which is empty).
342
348
  var proxy = new Proxy(target, {
343
349
  get: function (_, ruleName) {
350
+ // On property access, we identify if it is a rule or not.
344
351
  var rule = getRule(ruleName);
352
+ // If it is a rule, we wrap it with `genRuleCall` that adds the base enforce behavior
345
353
  if (rule) {
346
354
  return genRuleCall(proxy, rule, ruleName);
347
355
  }
348
356
  }
349
357
  });
350
358
  return proxy;
359
+ // This function is used to wrap a rule with the base enforce behavior
360
+ // It takes the target object, the rule function, and the rule name
361
+ // It then returns the rule, in a manner that can be used by enforce
351
362
  function genRuleCall(target, rule, ruleName) {
352
363
  return function ruleCall() {
353
364
  var args = [];
354
365
  for (var _i = 0; _i < arguments.length; _i++) {
355
366
  args[_i] = arguments[_i];
356
367
  }
368
+ // Order of operation:
369
+ // 1. Create a context with the value being enforced
370
+ // 2. Call the rule within the context, and pass over the arguments passed to it
371
+ // 3. Transform the result to the correct output format
357
372
  var transformedResult = ctx.run({ value: value }, function () {
358
373
  return transformResult.apply(void 0, __spreadArray([rule.apply(void 0, __spreadArray([value], args, false)), ruleName, value], args, false));
359
374
  });
375
+ // On rule failure (the result is false), we either throw an error
376
+ // or throw a string value if the rule has a message defined in it.
360
377
  vestUtils.invariant(transformedResult.pass, vestUtils.isNullish(transformedResult.message)
361
378
  ? "enforce/".concat(ruleName, " failed with ").concat(JSON.stringify(value))
362
379
  : vestUtils.StringObject(transformedResult.message));
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var n4s = require('n4s');
6
5
  var vestUtils = require('vest-utils');
6
+ var n4s = require('n4s');
7
7
 
8
8
  function ruleReturn(pass, message) {
9
9
  var output = { pass: pass };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("n4s"),n=require("vest-utils");function e(r,n){return r={pass:r},n&&(r.message=n),r}function t(){return e(!1)}function u(){return e(!0)}function i(r,n){try{return r.run(n)}catch(r){return t()}}function o(n,e){var t,o=function(t){var u=n[t],o=e[t];if(!(t=r.ctx.run({value:u,set:!0,meta:{key:t}},(function(){return i(o,u)}))).pass)return{value:t}};for(t in e){var a=o(t);if("object"==typeof a)return a.value}return u()}r.enforce.extend({isArrayOf:function(e,t){return function(r){return n.defaultTo(r,u())}(n.mapFirst(e,(function(n,e,u){e(!(u=r.ctx.run({value:n,set:!0,meta:{index:u}},(function(){return i(t,n)}))).pass,u)})))},loose:o,optional:function(r,e){return n.isNullish(r)?u():i(e,r)},shape:function(r,e){var i=o(r,e);if(!i.pass)return i;for(var a in r)if(!n.hasOwnProperty(e,a))return t();return u()}}),exports.partial=function(n){var e,t={};for(e in n)t[e]=r.enforce.optional(n[e]);return t};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("vest-utils"),n=require("n4s");function e(r,n){return r={pass:r},n&&(r.message=n),r}function t(){return e(!1)}function u(){return e(!0)}function i(r,n){try{return r.run(n)}catch(r){return t()}}function o(r,e){var t,o=function(t){var u=r[t],o=e[t];if(!(t=n.ctx.run({value:u,set:!0,meta:{key:t}},(function(){return i(o,u)}))).pass)return{value:t}};for(t in e){var a=o(t);if("object"==typeof a)return a.value}return u()}n.enforce.extend({isArrayOf:function(e,t){return function(n){return r.defaultTo(n,u())}(r.mapFirst(e,(function(r,e,u){e(!(u=n.ctx.run({value:r,set:!0,meta:{index:u}},(function(){return i(t,r)}))).pass,u)})))},loose:o,optional:function(n,e){return r.isNullish(n)?u():i(e,n)},shape:function(n,e){var i=o(n,e);if(!i.pass)return i;for(var a in n)if(!r.hasOwnProperty(e,a))return t();return u()}}),exports.partial=function(r){var e,t={};for(e in r)t[e]=n.enforce.optional(r[e]);return t};
@@ -1,5 +1,5 @@
1
- import { ctx } from 'n4s';
2
1
  import { defaultTo, assign, mapFirst, invariant, StringObject } from 'vest-utils';
2
+ import { ctx } from 'n4s';
3
3
 
4
4
  function ruleReturn(pass, message) {
5
5
  var output = { pass: pass };
@@ -1 +1 @@
1
- import{defaultTo as n,assign as t,mapFirst as r,invariant as u,StringObject as s}from"vest-utils";import{ctx as e}from"n4s";function o(n,t){return n={pass:n},t&&(n.message=t),n}export default function(){function a(t){return e.run({value:t},(function(){return n(r(f,(function(n,r){try{var u=n.run(t)}catch(n){u=o(!1)}r(!u.pass,u)})),o(!0))}))}for(var f=[],i=0;i<arguments.length;i++)f[i]=arguments[i];return t((function(n){n=a(n),u(n.pass,s(n.message))}),{run:a,test:function(n){return a(n).pass}})}
1
+ import{ctx as n}from"n4s";import{defaultTo as t,assign as r,mapFirst as u,invariant as s,StringObject as e}from"vest-utils";function o(n,t){return n={pass:n},t&&(n.message=t),n}export default function(){function a(r){return n.run({value:r},(function(){return t(u(f,(function(n,t){try{var u=n.run(r)}catch(n){u=o(!1)}t(!u.pass,u)})),o(!0))}))}for(var f=[],i=0;i<arguments.length;i++)f[i]=arguments[i];return r((function(n){n=a(n),s(n.pass,e(n.message))}),{run:a,test:function(n){return a(n).pass}})}
@@ -1,5 +1,5 @@
1
- import { enforce } from 'n4s';
2
1
  import { defaultTo, mapFirst, bindNot, greaterThan } from 'vest-utils';
2
+ import { enforce } from 'n4s';
3
3
 
4
4
  function ruleReturn(pass, message) {
5
5
  var output = { pass: pass };
@@ -1 +1 @@
1
- import{defaultTo as n,mapFirst as r,bindNot as t,greaterThan as f}from"vest-utils";import{enforce as o}from"n4s";function u(n,r){return n={pass:n},r&&(n.message=r),n}function e(n,r){try{return n.run(r)}catch(n){return u(!1)}}t((function(n,r){return n===r})),o.extend({allOf:function(t){for(var f=[],o=1;o<arguments.length;o++)f[o-1]=arguments[o];return n(r(f,(function(n,r){r(!(n=e(n,t)).pass,n)})),u(!0))},anyOf:function(t){for(var f=[],o=1;o<arguments.length;o++)f[o-1]=arguments[o];return n(r(f,(function(n,r){r((n=e(n,t)).pass,n)})),u(!1))},noneOf:function(t){for(var f=[],o=1;o<arguments.length;o++)f[o-1]=arguments[o];return n(r(f,(function(n,r){r((n=e(n,t)).pass,u(!1))})),u(!0))},oneOf:function(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var o=0;return r.some((function(r){if(e(r,n).pass&&o++,f(o,1))return!1})),u(1===o)}});
1
+ import{enforce as n}from"n4s";import{defaultTo as r,mapFirst as t,bindNot as f,greaterThan as o}from"vest-utils";function u(n,r){return n={pass:n},r&&(n.message=r),n}function e(n,r){try{return n.run(r)}catch(n){return u(!1)}}f((function(n,r){return n===r})),n.extend({allOf:function(n){for(var f=[],o=1;o<arguments.length;o++)f[o-1]=arguments[o];return r(t(f,(function(r,t){t(!(r=e(r,n)).pass,r)})),u(!0))},anyOf:function(n){for(var f=[],o=1;o<arguments.length;o++)f[o-1]=arguments[o];return r(t(f,(function(r,t){t((r=e(r,n)).pass,r)})),u(!1))},noneOf:function(n){for(var f=[],o=1;o<arguments.length;o++)f[o-1]=arguments[o];return r(t(f,(function(r,t){t((r=e(r,n)).pass,u(!1))})),u(!0))},oneOf:function(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var f=0;return r.some((function(r){if(e(r,n).pass&&f++,o(f,1))return!1})),u(1===f)}});
@@ -329,30 +329,47 @@ function validateResult(result) {
329
329
 
330
330
  function enforceEager(value) {
331
331
  var target = {};
332
+ // This condition is for when we don't have proxy support (ES5).
333
+ // In this case, we need to manually assign the rules to the target object on runtime.
334
+ // The follow up proxy block is used in case we do have proxy support, and we can assign each rule upon invocation.
332
335
  if (!isProxySupported()) {
336
+ // We iterate over each of the rules, and add them to the target object being return by enforce
333
337
  eachEnforceRule(function (ruleName, ruleFn) {
338
+ // We then wrap the rule with `genRuleCall` that adds the base enforce behavior
334
339
  target[ruleName] = genRuleCall(target, ruleFn, ruleName);
335
340
  });
336
341
  return target;
337
342
  }
343
+ // We create a proxy intercepting access to the target object (which is empty).
338
344
  var proxy = new Proxy(target, {
339
345
  get: function (_, ruleName) {
346
+ // On property access, we identify if it is a rule or not.
340
347
  var rule = getRule(ruleName);
348
+ // If it is a rule, we wrap it with `genRuleCall` that adds the base enforce behavior
341
349
  if (rule) {
342
350
  return genRuleCall(proxy, rule, ruleName);
343
351
  }
344
352
  }
345
353
  });
346
354
  return proxy;
355
+ // This function is used to wrap a rule with the base enforce behavior
356
+ // It takes the target object, the rule function, and the rule name
357
+ // It then returns the rule, in a manner that can be used by enforce
347
358
  function genRuleCall(target, rule, ruleName) {
348
359
  return function ruleCall() {
349
360
  var args = [];
350
361
  for (var _i = 0; _i < arguments.length; _i++) {
351
362
  args[_i] = arguments[_i];
352
363
  }
364
+ // Order of operation:
365
+ // 1. Create a context with the value being enforced
366
+ // 2. Call the rule within the context, and pass over the arguments passed to it
367
+ // 3. Transform the result to the correct output format
353
368
  var transformedResult = ctx.run({ value: value }, function () {
354
369
  return transformResult.apply(void 0, __spreadArray([rule.apply(void 0, __spreadArray([value], args, false)), ruleName, value], args, false));
355
370
  });
371
+ // On rule failure (the result is false), we either throw an error
372
+ // or throw a string value if the rule has a message defined in it.
356
373
  invariant(transformedResult.pass, isNullish(transformedResult.message)
357
374
  ? "enforce/".concat(ruleName, " failed with ").concat(JSON.stringify(value))
358
375
  : StringObject(transformedResult.message));
@@ -1,5 +1,5 @@
1
- import { ctx, enforce } from 'n4s';
2
1
  import { defaultTo, mapFirst, isNullish, hasOwnProperty } from 'vest-utils';
2
+ import { ctx, enforce } from 'n4s';
3
3
 
4
4
  function ruleReturn(pass, message) {
5
5
  var output = { pass: pass };
@@ -1 +1 @@
1
- import{defaultTo as r,mapFirst as n,isNullish as t,hasOwnProperty as e}from"vest-utils";import{ctx as u,enforce as o}from"n4s";function i(r,n){return r={pass:r},n&&(r.message=n),r}function a(r,n){try{return r.run(n)}catch(r){return i(!1)}}function f(r,n){function t(t){var e=r[t],o=n[t];if(!(t=u.run({value:e,set:!0,meta:{key:t}},(function(){return a(o,e)}))).pass)return{value:t}}for(var e in n){var o=t(e);if("object"==typeof o)return o.value}return i(!0)}o.extend({isArrayOf:function(t,e){return r(n(t,(function(r,n,t){n(!(t=u.run({value:r,set:!0,meta:{index:t}},(function(){return a(e,r)}))).pass,t)})),i(!0))},loose:f,optional:function(r,n){return t(r)?i(!0):a(n,r)},shape:function(r,n){var t=f(r,n);if(!t.pass)return t;for(var u in r)if(!e(n,u))return i(!1);return i(!0)}});export function partial(r){var n,t={};for(n in r)t[n]=o.optional(r[n]);return t}
1
+ import{ctx as r,enforce as n}from"n4s";import{defaultTo as t,mapFirst as e,isNullish as u,hasOwnProperty as o}from"vest-utils";function i(r,n){return r={pass:r},n&&(r.message=n),r}function a(r,n){try{return r.run(n)}catch(r){return i(!1)}}function f(n,t){function e(e){var u=n[e],o=t[e];if(!(e=r.run({value:u,set:!0,meta:{key:e}},(function(){return a(o,u)}))).pass)return{value:e}}for(var u in t){var o=e(u);if("object"==typeof o)return o.value}return i(!0)}n.extend({isArrayOf:function(n,u){return t(e(n,(function(n,t,e){t(!(e=r.run({value:n,set:!0,meta:{index:e}},(function(){return a(u,n)}))).pass,e)})),i(!0))},loose:f,optional:function(r,n){return u(r)?i(!0):a(n,r)},shape:function(r,n){var t=f(r,n);if(!t.pass)return t;for(var e in r)if(!o(n,e))return i(!1);return i(!0)}});export function partial(r){var t,e={};for(t in r)e[t]=n.optional(r[t]);return e}
@@ -529,30 +529,47 @@
529
529
 
530
530
  function enforceEager(value) {
531
531
  var target = {};
532
+ // This condition is for when we don't have proxy support (ES5).
533
+ // In this case, we need to manually assign the rules to the target object on runtime.
534
+ // The follow up proxy block is used in case we do have proxy support, and we can assign each rule upon invocation.
532
535
  if (!isProxySupported()) {
536
+ // We iterate over each of the rules, and add them to the target object being return by enforce
533
537
  eachEnforceRule(function (ruleName, ruleFn) {
538
+ // We then wrap the rule with `genRuleCall` that adds the base enforce behavior
534
539
  target[ruleName] = genRuleCall(target, ruleFn, ruleName);
535
540
  });
536
541
  return target;
537
542
  }
543
+ // We create a proxy intercepting access to the target object (which is empty).
538
544
  var proxy = new Proxy(target, {
539
545
  get: function (_, ruleName) {
546
+ // On property access, we identify if it is a rule or not.
540
547
  var rule = getRule(ruleName);
548
+ // If it is a rule, we wrap it with `genRuleCall` that adds the base enforce behavior
541
549
  if (rule) {
542
550
  return genRuleCall(proxy, rule, ruleName);
543
551
  }
544
552
  }
545
553
  });
546
554
  return proxy;
555
+ // This function is used to wrap a rule with the base enforce behavior
556
+ // It takes the target object, the rule function, and the rule name
557
+ // It then returns the rule, in a manner that can be used by enforce
547
558
  function genRuleCall(target, rule, ruleName) {
548
559
  return function ruleCall() {
549
560
  var args = [];
550
561
  for (var _i = 0; _i < arguments.length; _i++) {
551
562
  args[_i] = arguments[_i];
552
563
  }
564
+ // Order of operation:
565
+ // 1. Create a context with the value being enforced
566
+ // 2. Call the rule within the context, and pass over the arguments passed to it
567
+ // 3. Transform the result to the correct output format
553
568
  var transformedResult = ctx.run({ value: value }, function () {
554
569
  return transformResult.apply(void 0, __spreadArray([rule.apply(void 0, __spreadArray([value], args, false)), ruleName, value], args, false));
555
570
  });
571
+ // On rule failure (the result is false), we either throw an error
572
+ // or throw a string value if the rule has a message defined in it.
556
573
  invariant(transformedResult.pass, isNullish(transformedResult.message)
557
574
  ? "enforce/".concat(ruleName, " failed with ").concat(JSON.stringify(value))
558
575
  : StringObject(transformedResult.message));
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.1.9-dev-c786f7",
2
+ "version": "4.1.9-dev-9b46fb",
3
3
  "license": "MIT",
4
4
  "main": "./dist/cjs/n4s.js",
5
5
  "types": "./types/n4s.d.ts",
@@ -10,8 +10,8 @@
10
10
  "release": "vx release"
11
11
  },
12
12
  "dependencies": {
13
- "context": "^2.0.8-dev-c786f7",
14
- "vest-utils": "^0.0.4-dev-c786f7"
13
+ "context": "^2.0.8-dev-9b46fb",
14
+ "vest-utils": "^0.0.2-dev-9b46fb"
15
15
  },
16
16
  "module": "./dist/es/n4s.production.js",
17
17
  "exports": {
@@ -3,6 +3,7 @@ type DropFirst<T extends unknown[]> = T extends [
3
3
  ...infer U
4
4
  ] ? U : never;
5
5
  type Stringable = string | ((...args: any[]) => string);
6
+ type CB = (...args: any[]) => any;
6
7
  type RuleReturn = boolean | {
7
8
  pass: boolean;
8
9
  message?: Stringable;
@@ -111,7 +112,7 @@ type LazyRules = n4s.IRules<LazyRuleMethods>;
111
112
  type Lazy = LazyRules & LazyRuleMethods &
112
113
  // This is a "catch all" hack to make TS happy while not
113
114
  // losing type hints
114
- Record<string, (...args: any[]) => any>;
115
+ Record<string, CB>;
115
116
  type LazyRuleMethods = LazyRuleRunners & {
116
117
  message: (message: LazyMessage) => Lazy;
117
118
  };
@@ -3,6 +3,7 @@ type DropFirst<T extends unknown[]> = T extends [
3
3
  ...infer U
4
4
  ] ? U : never;
5
5
  type Stringable = string | ((...args: any[]) => string);
6
+ type CB = (...args: any[]) => any;
6
7
  type RuleReturn = boolean | {
7
8
  pass: boolean;
8
9
  message?: Stringable;
@@ -111,7 +112,7 @@ type LazyRules = n4s.IRules<LazyRuleMethods>;
111
112
  type Lazy = LazyRules & LazyRuleMethods &
112
113
  // This is a "catch all" hack to make TS happy while not
113
114
  // losing type hints
114
- Record<string, (...args: any[]) => any>;
115
+ Record<string, CB>;
115
116
  type LazyRuleMethods = LazyRuleRunners & {
116
117
  message: (message: LazyMessage) => Lazy;
117
118
  };
package/types/n4s.d.ts CHANGED
@@ -20,6 +20,7 @@ type DropFirst<T extends unknown[]> = T extends [
20
20
  ...infer U
21
21
  ] ? U : never;
22
22
  type Stringable = string | ((...args: any[]) => string);
23
+ type CB = (...args: any[]) => any;
23
24
  type RuleReturn = boolean | {
24
25
  pass: boolean;
25
26
  message?: Stringable;
@@ -134,7 +135,7 @@ type LazyRules = n4s.IRules<LazyRuleMethods>;
134
135
  type Lazy = LazyRules & LazyRuleMethods &
135
136
  // This is a "catch all" hack to make TS happy while not
136
137
  // losing type hints
137
- Record<string, (...args: any[]) => any>;
138
+ Record<string, CB>;
138
139
  type LazyRuleMethods = LazyRuleRunners & {
139
140
  message: (message: LazyMessage) => Lazy;
140
141
  };
package/types/schema.d.ts CHANGED
@@ -3,6 +3,7 @@ type DropFirst<T extends unknown[]> = T extends [
3
3
  ...infer U
4
4
  ] ? U : never;
5
5
  type Stringable = string | ((...args: any[]) => string);
6
+ type CB = (...args: any[]) => any;
6
7
  type RuleReturn = boolean | {
7
8
  pass: boolean;
8
9
  message?: Stringable;
@@ -111,7 +112,7 @@ type LazyRules = n4s.IRules<LazyRuleMethods>;
111
112
  type Lazy = LazyRules & LazyRuleMethods &
112
113
  // This is a "catch all" hack to make TS happy while not
113
114
  // losing type hints
114
- Record<string, (...args: any[]) => any>;
115
+ Record<string, CB>;
115
116
  type LazyRuleMethods = LazyRuleRunners & {
116
117
  message: (message: LazyMessage) => Lazy;
117
118
  };