phecda-core 2.0.0-alpha.0 → 2.0.0-alpha.1

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.
package/dist/index.d.ts CHANGED
@@ -77,7 +77,7 @@ declare function addDecoToClass<M extends new (...args: any) => any>(c: M, key:
77
77
 
78
78
  declare function Init(target: any, key: PropertyKey): void;
79
79
  declare function Bind(value: any): (target: any, k: PropertyKey) => void;
80
- declare function Rule(rule: RegExp | string | Function | number, info: string, meta?: any): (obj: any, key: PropertyKey) => void;
80
+ declare function Rule(rule: RegExp | string | Function | number, info: string | ((k: string) => string), meta?: any): (obj: any, key: PropertyKey) => void;
81
81
  declare function Ignore(target: any, key: PropertyKey): void;
82
82
  declare function Clear(target: any, key: PropertyKey): void;
83
83
  declare function Err<Fn extends (...args: any) => any>(cb: Fn): (target: any, key: PropertyKey) => void;
@@ -412,7 +412,7 @@ var Phecda = (() => {
412
412
  for (const handler of handlers) {
413
413
  const rule = handler.rule;
414
414
  if (rule && !await validate(rule, data[item])) {
415
- err.push(handler.info || "");
415
+ err.push(typeof handler.info === "function" ? handler.info(item) : handler.info);
416
416
  if (!options.collectError)
417
417
  break;
418
418
  }
package/dist/index.js CHANGED
@@ -412,7 +412,7 @@ async function plainToClass(Model, input, options = {}) {
412
412
  for (const handler of handlers) {
413
413
  const rule = handler.rule;
414
414
  if (rule && !await validate(rule, data[item])) {
415
- err.push(handler.info || "");
415
+ err.push(typeof handler.info === "function" ? handler.info(item) : handler.info);
416
416
  if (!options.collectError)
417
417
  break;
418
418
  }
package/dist/index.mjs CHANGED
@@ -339,7 +339,7 @@ async function plainToClass(Model, input, options = {}) {
339
339
  for (const handler of handlers) {
340
340
  const rule = handler.rule;
341
341
  if (rule && !await validate(rule, data[item])) {
342
- err.push(handler.info || "");
342
+ err.push(typeof handler.info === "function" ? handler.info(item) : handler.info);
343
343
  if (!options.collectError)
344
344
  break;
345
345
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-core",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "provide base function and abstract limit to other phecda module ",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",