@arcblock/validator 1.27.15 → 1.28.0

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.
@@ -0,0 +1,2 @@
1
+ //#region src/lodash.d.ts
2
+ declare module 'lodash/isEqual';
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1,96 +1,100 @@
1
- import { Root, AnySchema } from 'joi';
2
- import BN from 'bn.js';
3
- export interface BNSchema extends AnySchema {
4
- min(threshold: any): this;
5
- gte(threshold: any): this;
6
- max(threshold: any): this;
7
- lte(threshold: any): this;
8
- greater(threshold: any): this;
9
- gt(threshold: any): this;
10
- less(threshold: any): this;
11
- lt(threshold: any): this;
12
- positive(): this;
13
- negative(): this;
1
+ import { AnySchema, Root } from "joi";
2
+ import BN from "bn.js";
3
+
4
+ //#region src/extension/bn.d.ts
5
+ interface BNSchema extends AnySchema {
6
+ min(threshold: any): this;
7
+ gte(threshold: any): this;
8
+ max(threshold: any): this;
9
+ lte(threshold: any): this;
10
+ greater(threshold: any): this;
11
+ gt(threshold: any): this;
12
+ less(threshold: any): this;
13
+ lt(threshold: any): this;
14
+ positive(): this;
15
+ negative(): this;
14
16
  }
15
- export declare function BNExtension(root: Root): {
16
- type: string;
17
- base: AnySchema<any>;
18
- messages: {
19
- 'bn.nan': string;
20
- 'bn.max': string;
21
- 'bn.min': string;
22
- 'bn.less': string;
23
- 'bn.greater': string;
24
- 'bn.positive': string;
25
- 'bn.negative': string;
17
+ declare function BNExtension(root: Root): {
18
+ type: string;
19
+ base: AnySchema<any>;
20
+ messages: {
21
+ 'bn.nan': string;
22
+ 'bn.max': string;
23
+ 'bn.min': string;
24
+ 'bn.less': string;
25
+ 'bn.greater': string;
26
+ 'bn.positive': string;
27
+ 'bn.negative': string;
28
+ };
29
+ prepare(value: any, helpers: any): {
30
+ value: BN;
31
+ errors?: undefined;
32
+ } | {
33
+ errors: any;
34
+ value?: undefined;
35
+ };
36
+ coerce(value: BN): {
37
+ value: string;
38
+ };
39
+ validate(value: any): {
40
+ value: any;
41
+ };
42
+ rules: {
43
+ gt: {
44
+ args: ({
45
+ name: string;
46
+ ref: boolean;
47
+ assert: (v: any) => v is BN;
48
+ message: string;
49
+ normalize: (v: any) => BN;
50
+ } | {
51
+ name: string;
52
+ assert: (v: any) => v is boolean;
53
+ message: string;
54
+ ref?: undefined;
55
+ normalize?: undefined;
56
+ })[];
57
+ validate(value: any, helpers: any, args: any): any;
26
58
  };
27
- prepare(value: any, helpers: any): {
28
- value: BN;
29
- errors?: undefined;
30
- } | {
31
- errors: any;
32
- value?: undefined;
59
+ lt: {
60
+ args: ({
61
+ name: string;
62
+ ref: boolean;
63
+ assert: (v: any) => v is BN;
64
+ message: string;
65
+ normalize: (v: any) => BN;
66
+ } | {
67
+ name: string;
68
+ assert: (v: any) => v is boolean;
69
+ message: string;
70
+ ref?: undefined;
71
+ normalize?: undefined;
72
+ })[];
73
+ validate(value: any, helpers: any, args: any): any;
33
74
  };
34
- coerce(value: BN): {
35
- value: string;
75
+ min: {
76
+ alias: string;
77
+ method(threshold: any): BNSchema;
36
78
  };
37
- validate(value: any): {
38
- value: any;
79
+ max: {
80
+ alias: string;
81
+ method(threshold: any): BNSchema;
39
82
  };
40
- rules: {
41
- gt: {
42
- args: ({
43
- name: string;
44
- ref: boolean;
45
- assert: (v: any) => v is BN;
46
- message: string;
47
- normalize: (v: any) => BN;
48
- } | {
49
- name: string;
50
- assert: (v: any) => v is boolean;
51
- message: string;
52
- ref?: undefined;
53
- normalize?: undefined;
54
- })[];
55
- validate(value: any, helpers: any, args: any): any;
56
- };
57
- lt: {
58
- args: ({
59
- name: string;
60
- ref: boolean;
61
- assert: (v: any) => v is BN;
62
- message: string;
63
- normalize: (v: any) => BN;
64
- } | {
65
- name: string;
66
- assert: (v: any) => v is boolean;
67
- message: string;
68
- ref?: undefined;
69
- normalize?: undefined;
70
- })[];
71
- validate(value: any, helpers: any, args: any): any;
72
- };
73
- min: {
74
- alias: string;
75
- method(threshold: any): BNSchema;
76
- };
77
- max: {
78
- alias: string;
79
- method(threshold: any): BNSchema;
80
- };
81
- greater: {
82
- alias: string;
83
- method(threshold: any): BNSchema;
84
- };
85
- less: {
86
- alias: string;
87
- method(threshold: any): BNSchema;
88
- };
89
- positive: {
90
- method(): BNSchema;
91
- };
92
- negative: {
93
- method(): BNSchema;
94
- };
83
+ greater: {
84
+ alias: string;
85
+ method(threshold: any): BNSchema;
95
86
  };
87
+ less: {
88
+ alias: string;
89
+ method(threshold: any): BNSchema;
90
+ };
91
+ positive: {
92
+ method(): BNSchema;
93
+ };
94
+ negative: {
95
+ method(): BNSchema;
96
+ };
97
+ };
96
98
  };
99
+ //#endregion
100
+ export { BNExtension, BNSchema };
@@ -1,136 +1,142 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BNExtension = BNExtension;
7
- const bn_js_1 = __importDefault(require("bn.js"));
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ let bn_js = require("bn.js");
3
+ bn_js = require_rolldown_runtime.__toESM(bn_js);
4
+
5
+ //#region src/extension/bn.ts
8
6
  function BNExtension(root) {
9
- return {
10
- type: 'BN',
11
- base: root.any(),
12
- messages: {
13
- 'bn.nan': '{{#label}} is not a big number',
14
- 'bn.max': '{{#label}} needs to be less than or equal to "{{#threshold}}"',
15
- 'bn.min': '{{#label}} needs to be greater than or equal to "{{#threshold}}"',
16
- 'bn.less': '{{#label}} needs to be less than "{{#threshold}}"',
17
- 'bn.greater': '{{#label}} needs to be greater than "{{#threshold}}"',
18
- 'bn.positive': '{{#label}} needs to be positive',
19
- 'bn.negative': '{{#label}} needs to be negative',
20
- },
21
- prepare(value, helpers) {
22
- try {
23
- return { value: new bn_js_1.default(value) };
24
- }
25
- catch (err) {
26
- return { errors: helpers.error('bn.nan') };
27
- }
28
- },
29
- coerce(value) {
30
- return { value: value.toString(10) };
31
- },
32
- validate(value) {
33
- return { value };
34
- },
35
- rules: {
36
- gt: {
37
- args: [
38
- {
39
- name: 'threshold',
40
- ref: true,
41
- assert: (v) => bn_js_1.default.isBN(v),
42
- message: 'must be a big number',
43
- normalize: (v) => new bn_js_1.default(v),
44
- },
45
- {
46
- name: 'equal',
47
- assert: (v) => typeof v === 'boolean',
48
- message: 'must be a boolean',
49
- },
50
- ],
51
- // The rule return structure is different from the root
52
- // eslint-disable-next-line consistent-return
53
- validate(value, helpers, args) {
54
- const v = new bn_js_1.default(value);
55
- if (args.equal && v.lt(args.threshold)) {
56
- return helpers.error('bn.min', args);
57
- }
58
- if (!args.equal && v.lte(args.threshold)) {
59
- return helpers.error('bn.greater', args);
60
- }
61
- // must return value when valid
62
- return value;
63
- },
64
- },
65
- lt: {
66
- args: [
67
- {
68
- name: 'threshold',
69
- ref: true,
70
- assert: (v) => bn_js_1.default.isBN(v),
71
- message: 'must be a big number',
72
- normalize: (v) => new bn_js_1.default(v),
73
- },
74
- {
75
- name: 'equal',
76
- assert: (v) => typeof v === 'boolean',
77
- message: 'must be a boolean',
78
- },
79
- ],
80
- // The rule return structure is different from the root
81
- // eslint-disable-next-line consistent-return
82
- validate(value, helpers, args) {
83
- const v = new bn_js_1.default(value);
84
- if (args.equal && v.gt(args.threshold)) {
85
- return helpers.error('bn.max', args);
86
- }
87
- if (!args.equal && v.gte(args.threshold)) {
88
- return helpers.error('bn.less', args);
89
- }
90
- // must return value when valid
91
- return value;
92
- },
93
- },
94
- min: {
95
- alias: 'gte',
96
- method(threshold) {
97
- // @ts-ignore
98
- return this.$_addRule({ name: 'gt', args: { threshold, equal: true } });
99
- },
100
- },
101
- max: {
102
- alias: 'lte',
103
- method(threshold) {
104
- // @ts-ignore
105
- return this.$_addRule({ name: 'lt', args: { threshold, equal: true } });
106
- },
107
- },
108
- greater: {
109
- alias: 'gt',
110
- method(threshold) {
111
- // @ts-ignore
112
- return this.$_addRule({ name: 'gt', args: { threshold, equal: false } });
113
- },
114
- },
115
- less: {
116
- alias: 'lt',
117
- method(threshold) {
118
- // @ts-ignore
119
- return this.$_addRule({ name: 'lt', args: { threshold, equal: false } });
120
- },
121
- },
122
- positive: {
123
- method() {
124
- // @ts-ignore
125
- return this.$_addRule({ name: 'gt', args: { threshold: 0, equal: false } });
126
- },
127
- },
128
- negative: {
129
- method() {
130
- // @ts-ignore
131
- return this.$_addRule({ name: 'lt', args: { threshold: 0, equal: false } });
132
- },
133
- },
134
- },
135
- };
7
+ return {
8
+ type: "BN",
9
+ base: root.any(),
10
+ messages: {
11
+ "bn.nan": "{{#label}} is not a big number",
12
+ "bn.max": "{{#label}} needs to be less than or equal to \"{{#threshold}}\"",
13
+ "bn.min": "{{#label}} needs to be greater than or equal to \"{{#threshold}}\"",
14
+ "bn.less": "{{#label}} needs to be less than \"{{#threshold}}\"",
15
+ "bn.greater": "{{#label}} needs to be greater than \"{{#threshold}}\"",
16
+ "bn.positive": "{{#label}} needs to be positive",
17
+ "bn.negative": "{{#label}} needs to be negative"
18
+ },
19
+ prepare(value, helpers) {
20
+ try {
21
+ return { value: new bn_js.default(value) };
22
+ } catch (err) {
23
+ return { errors: helpers.error("bn.nan") };
24
+ }
25
+ },
26
+ coerce(value) {
27
+ return { value: value.toString(10) };
28
+ },
29
+ validate(value) {
30
+ return { value };
31
+ },
32
+ rules: {
33
+ gt: {
34
+ args: [{
35
+ name: "threshold",
36
+ ref: true,
37
+ assert: (v) => bn_js.default.isBN(v),
38
+ message: "must be a big number",
39
+ normalize: (v) => new bn_js.default(v)
40
+ }, {
41
+ name: "equal",
42
+ assert: (v) => typeof v === "boolean",
43
+ message: "must be a boolean"
44
+ }],
45
+ validate(value, helpers, args) {
46
+ const v = new bn_js.default(value);
47
+ if (args.equal && v.lt(args.threshold)) return helpers.error("bn.min", args);
48
+ if (!args.equal && v.lte(args.threshold)) return helpers.error("bn.greater", args);
49
+ return value;
50
+ }
51
+ },
52
+ lt: {
53
+ args: [{
54
+ name: "threshold",
55
+ ref: true,
56
+ assert: (v) => bn_js.default.isBN(v),
57
+ message: "must be a big number",
58
+ normalize: (v) => new bn_js.default(v)
59
+ }, {
60
+ name: "equal",
61
+ assert: (v) => typeof v === "boolean",
62
+ message: "must be a boolean"
63
+ }],
64
+ validate(value, helpers, args) {
65
+ const v = new bn_js.default(value);
66
+ if (args.equal && v.gt(args.threshold)) return helpers.error("bn.max", args);
67
+ if (!args.equal && v.gte(args.threshold)) return helpers.error("bn.less", args);
68
+ return value;
69
+ }
70
+ },
71
+ min: {
72
+ alias: "gte",
73
+ method(threshold) {
74
+ return this.$_addRule({
75
+ name: "gt",
76
+ args: {
77
+ threshold,
78
+ equal: true
79
+ }
80
+ });
81
+ }
82
+ },
83
+ max: {
84
+ alias: "lte",
85
+ method(threshold) {
86
+ return this.$_addRule({
87
+ name: "lt",
88
+ args: {
89
+ threshold,
90
+ equal: true
91
+ }
92
+ });
93
+ }
94
+ },
95
+ greater: {
96
+ alias: "gt",
97
+ method(threshold) {
98
+ return this.$_addRule({
99
+ name: "gt",
100
+ args: {
101
+ threshold,
102
+ equal: false
103
+ }
104
+ });
105
+ }
106
+ },
107
+ less: {
108
+ alias: "lt",
109
+ method(threshold) {
110
+ return this.$_addRule({
111
+ name: "lt",
112
+ args: {
113
+ threshold,
114
+ equal: false
115
+ }
116
+ });
117
+ }
118
+ },
119
+ positive: { method() {
120
+ return this.$_addRule({
121
+ name: "gt",
122
+ args: {
123
+ threshold: 0,
124
+ equal: false
125
+ }
126
+ });
127
+ } },
128
+ negative: { method() {
129
+ return this.$_addRule({
130
+ name: "lt",
131
+ args: {
132
+ threshold: 0,
133
+ equal: false
134
+ }
135
+ });
136
+ } }
137
+ }
138
+ };
136
139
  }
140
+
141
+ //#endregion
142
+ exports.BNExtension = BNExtension;
@@ -1,77 +1,81 @@
1
- import { Root, StringSchema } from 'joi';
2
- import { KeyType, HashType, RoleType } from '@ocap/mcrypto';
3
- import { DIDTypeShortcut } from '@arcblock/did';
4
- export interface DIDSchema extends StringSchema {
5
- wallet(type: DIDTypeShortcut): this;
6
- pk(type: KeyType): this;
7
- hash(type: HashType): this;
8
- role(type: RoleType): this;
9
- prefix(str?: string): this;
1
+ import { Root, StringSchema } from "joi";
2
+ import { HashType, KeyType, RoleType } from "@ocap/mcrypto";
3
+ import { DIDTypeShortcut } from "@arcblock/did";
4
+
5
+ //#region src/extension/did.d.ts
6
+ interface DIDSchema extends StringSchema {
7
+ wallet(type: DIDTypeShortcut): this;
8
+ pk(type: KeyType): this;
9
+ hash(type: HashType): this;
10
+ role(type: RoleType): this;
11
+ prefix(str?: string): this;
10
12
  }
11
- export declare function DIDExtension(root: Root): {
12
- type: string;
13
- base: StringSchema<string>;
14
- messages: {
15
- 'did.empty': string;
16
- 'did.invalid': string;
17
- 'did.wallet': string;
18
- 'did.pk': string;
19
- 'did.hash': string;
20
- 'did.role': string;
21
- 'did.prefix': string;
13
+ declare function DIDExtension(root: Root): {
14
+ type: string;
15
+ base: StringSchema<string>;
16
+ messages: {
17
+ 'did.empty': string;
18
+ 'did.invalid': string;
19
+ 'did.wallet': string;
20
+ 'did.pk': string;
21
+ 'did.hash': string;
22
+ 'did.role': string;
23
+ 'did.prefix': string;
24
+ };
25
+ validate(value: any, helpers: any): {
26
+ errors: any;
27
+ value?: undefined;
28
+ } | {
29
+ value: string;
30
+ errors?: undefined;
31
+ };
32
+ rules: {
33
+ type: {
34
+ args: ({
35
+ name: string;
36
+ ref: boolean;
37
+ assert: (v: string) => boolean;
38
+ message: string;
39
+ } | {
40
+ name: string;
41
+ assert: (v: string) => boolean;
42
+ message: string;
43
+ ref?: undefined;
44
+ })[];
45
+ validate(value: string, helpers: any, args: any): any;
22
46
  };
23
- validate(value: any, helpers: any): {
24
- errors: any;
25
- value?: undefined;
26
- } | {
27
- value: string;
28
- errors?: undefined;
47
+ pk: {
48
+ method(type: KeyType): DIDSchema;
29
49
  };
30
- rules: {
31
- type: {
32
- args: ({
33
- name: string;
34
- ref: boolean;
35
- assert: (v: string) => boolean;
36
- message: string;
37
- } | {
38
- name: string;
39
- assert: (v: string) => boolean;
40
- message: string;
41
- ref?: undefined;
42
- })[];
43
- validate(value: string, helpers: any, args: any): any;
44
- };
45
- pk: {
46
- method(type: KeyType): DIDSchema;
47
- };
48
- hash: {
49
- method(type: HashType): DIDSchema;
50
- };
51
- role: {
52
- method(type: RoleType): DIDSchema;
53
- };
54
- wallet: {
55
- method(type: DIDTypeShortcut): DIDSchema;
56
- args: {
57
- name: string;
58
- ref: boolean;
59
- assert: (v: any) => boolean;
60
- message: string;
61
- normalize: (v: any) => any;
62
- }[];
63
- validate(value: any, helpers: any, args?: any): any;
64
- };
65
- prefix: {
66
- method(str?: string): DIDSchema;
67
- args: {
68
- name: string;
69
- ref: boolean;
70
- assert: (v: any) => boolean;
71
- message: string;
72
- normalize: (v: any) => any;
73
- }[];
74
- validate(value: any, helpers: any, args?: any): any;
75
- };
50
+ hash: {
51
+ method(type: HashType): DIDSchema;
76
52
  };
53
+ role: {
54
+ method(type: RoleType): DIDSchema;
55
+ };
56
+ wallet: {
57
+ method(type: DIDTypeShortcut): DIDSchema;
58
+ args: {
59
+ name: string;
60
+ ref: boolean;
61
+ assert: (v: any) => boolean;
62
+ message: string;
63
+ normalize: (v: any) => any;
64
+ }[];
65
+ validate(value: any, helpers: any, args?: any): any;
66
+ };
67
+ prefix: {
68
+ method(str?: string): DIDSchema;
69
+ args: {
70
+ name: string;
71
+ ref: boolean;
72
+ assert: (v: any) => boolean;
73
+ message: string;
74
+ normalize: (v: any) => any;
75
+ }[];
76
+ validate(value: any, helpers: any, args?: any): any;
77
+ };
78
+ };
77
79
  };
80
+ //#endregion
81
+ export { DIDExtension, DIDSchema };