phecda-vue 2.0.3 → 2.0.4-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.js CHANGED
@@ -589,6 +589,18 @@ __name(createFormData, "createFormData");
589
589
 
590
590
  // src/components/formResolve.ts
591
591
  var import_phecda_core3 = require("phecda-core");
592
+ async function validate(p, v) {
593
+ if (typeof p === "string" || typeof p === "number") {
594
+ if (v === p)
595
+ return true;
596
+ }
597
+ if (typeof p === "function")
598
+ return p(v);
599
+ if (p instanceof RegExp)
600
+ return p.test(v);
601
+ return false;
602
+ }
603
+ __name(validate, "validate");
592
604
  function getElementPlusRules(Model, options = {}) {
593
605
  const stateVars = (0, import_phecda_core3.getExposeKey)(Model);
594
606
  const ret = {};
@@ -602,7 +614,7 @@ function getElementPlusRules(Model, options = {}) {
602
614
  ret[item] = [];
603
615
  ret[item].push({
604
616
  validator: async (_, value, callback) => {
605
- if (!await (0, import_phecda_core3.validate)(rule, value))
617
+ if (!await validate(rule, value))
606
618
  callback(new Error(info || ""));
607
619
  else
608
620
  callback();
@@ -631,7 +643,7 @@ function getNaiveUIRules(Model, options = {}) {
631
643
  ret[item] = [];
632
644
  ret[item].push({
633
645
  validator: async (_, value) => {
634
- if (!await (0, import_phecda_core3.validate)(rule, value))
646
+ if (!await validate(rule, value))
635
647
  return Promise.reject(info);
636
648
  else
637
649
  return Promise.resolve();
@@ -660,7 +672,7 @@ function getNutUIRules(Model, options = {}) {
660
672
  ret[item] = [];
661
673
  ret[item].push({
662
674
  validator: async (_, value) => {
663
- if (!await (0, import_phecda_core3.validate)(rule, value))
675
+ if (!await validate(rule, value))
664
676
  return false;
665
677
  else
666
678
  return true;
@@ -690,7 +702,7 @@ function getArcoRules(Model, options = {}) {
690
702
  ret[item] = [];
691
703
  ret[item].push({
692
704
  validator: async (value, cb) => {
693
- if (!await (0, import_phecda_core3.validate)(rule, value))
705
+ if (!await validate(rule, value))
694
706
  cb(info);
695
707
  },
696
708
  ...options,
package/dist/index.mjs CHANGED
@@ -527,7 +527,19 @@ function createFormData(schema, initData = {}, options = {}) {
527
527
  __name(createFormData, "createFormData");
528
528
 
529
529
  // src/components/formResolve.ts
530
- import { getExposeKey, getHandler as getHandler2, validate } from "phecda-core";
530
+ import { getExposeKey, getHandler as getHandler2 } from "phecda-core";
531
+ async function validate(p, v) {
532
+ if (typeof p === "string" || typeof p === "number") {
533
+ if (v === p)
534
+ return true;
535
+ }
536
+ if (typeof p === "function")
537
+ return p(v);
538
+ if (p instanceof RegExp)
539
+ return p.test(v);
540
+ return false;
541
+ }
542
+ __name(validate, "validate");
531
543
  function getElementPlusRules(Model, options = {}) {
532
544
  const stateVars = getExposeKey(Model);
533
545
  const ret = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-vue",
3
- "version": "2.0.3",
3
+ "version": "2.0.4-alpha.1",
4
4
  "description": "provide store/form/table with phecda function to vue",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "mitt": "^3.0.0",
16
16
  "vue": "^3.2.45",
17
- "phecda-core": "2.0.0"
17
+ "phecda-core": "2.1.0-alpha.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "tsup": "^6.5.0"