@based/schema 2.5.3 → 2.7.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.
- package/dist/src/compat/Untitled-1.d.ts +3 -0
- package/dist/src/compat/Untitled-1.js +205 -0
- package/dist/src/compat/index.d.ts +2 -0
- package/dist/src/compat/index.js +3 -0
- package/dist/src/compat/newToOld.d.ts +3 -0
- package/dist/src/compat/newToOld.js +213 -0
- package/dist/src/compat/oldSchemaType.d.ts +69 -0
- package/dist/src/compat/oldSchemaType.js +2 -0
- package/dist/src/compat/oldToNew.d.ts +3 -0
- package/dist/src/compat/oldToNew.js +210 -0
- package/dist/src/display/number.d.ts +2 -1
- package/dist/src/display/number.js +10 -0
- package/dist/src/display/string.d.ts +3 -1
- package/dist/src/display/string.js +5 -0
- package/dist/src/display/timestamp.d.ts +3 -1
- package/dist/src/display/timestamp.js +9 -0
- package/dist/src/error.d.ts +3 -1
- package/dist/src/error.js +2 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +2 -1
- package/dist/src/types.d.ts +4 -3
- package/dist/src/types.js +74 -0
- package/dist/src/validateSchema/basedSchemaTypeValidator.d.ts +3 -0
- package/dist/src/validateSchema/basedSchemaTypeValidator.js +45 -0
- package/dist/src/validateSchema/fieldValidators.d.ts +27 -0
- package/dist/src/validateSchema/fieldValidators.js +352 -0
- package/dist/src/validateSchema/index.d.ts +17 -0
- package/dist/src/validateSchema/index.js +109 -0
- package/dist/src/validateSchema/utils.d.ts +21 -0
- package/dist/src/validateSchema/utils.js +53 -0
- package/dist/test/compat.js +15 -0
- package/dist/test/data/newSchemas.d.ts +2 -0
- package/dist/test/data/newSchemas.js +254 -0
- package/dist/test/data/oldSchemas.d.ts +2 -0
- package/dist/test/data/oldSchemas.js +5058 -0
- package/dist/test/validateSchema/basic.d.ts +1 -0
- package/dist/test/validateSchema/basic.js +94 -0
- package/dist/test/validateSchema/fields.d.ts +1 -0
- package/dist/test/validateSchema/fields.js +366 -0
- package/dist/test/validateSchema/languages.d.ts +1 -0
- package/dist/test/validateSchema/languages.js +124 -0
- package/package.json +4 -1
- package/dist/src/validateSchema.d.ts +0 -4
- package/dist/src/validateSchema.js +0 -35
- package/dist/test/validateSchema.js +0 -38
- /package/dist/test/{validateSchema.d.ts → compat.d.ts} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
const DEFAULT_FIELDS = {
|
|
2
|
+
// id: { type: 'string' },
|
|
3
|
+
// createdAt: { type: 'timestamp' },
|
|
4
|
+
// updatedAt: { type: 'timestamp' },
|
|
5
|
+
// type: { type: 'string' },
|
|
6
|
+
// parents: { type: 'references' },
|
|
7
|
+
// children: { type: 'references' },
|
|
8
|
+
// ancestors: { type: 'references' },
|
|
9
|
+
// descendants: { type: 'references' },
|
|
10
|
+
// aliases: {
|
|
11
|
+
// type: 'set',
|
|
12
|
+
// items: { type: 'string' },
|
|
13
|
+
// },
|
|
14
|
+
};
|
|
15
|
+
const metaParser = (obj) => {
|
|
16
|
+
const metaObj = obj?.meta;
|
|
17
|
+
const tmp = {};
|
|
18
|
+
for (const i in metaObj) {
|
|
19
|
+
if (i === 'name') {
|
|
20
|
+
tmp.title = metaObj[i];
|
|
21
|
+
}
|
|
22
|
+
else if (i === 'validation' ||
|
|
23
|
+
i === 'progress' ||
|
|
24
|
+
i === 'format' ||
|
|
25
|
+
i === 'ui') {
|
|
26
|
+
if (metaObj[i] === 'url') {
|
|
27
|
+
// tmp.format = 'URL'
|
|
28
|
+
}
|
|
29
|
+
if ((metaObj[i] === 'bytes' && obj.type === 'number') ||
|
|
30
|
+
metaObj.type === 'float') {
|
|
31
|
+
tmp.display = 'bytes';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
tmp[i] = metaObj[i];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return tmp;
|
|
39
|
+
};
|
|
40
|
+
const migrateField = (oldField) => {
|
|
41
|
+
switch (oldField.type) {
|
|
42
|
+
case 'object':
|
|
43
|
+
return {
|
|
44
|
+
...metaParser(oldField),
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: migrateFields(oldField.properties, true),
|
|
47
|
+
};
|
|
48
|
+
case 'json':
|
|
49
|
+
return {
|
|
50
|
+
...oldField,
|
|
51
|
+
...metaParser(oldField),
|
|
52
|
+
type: 'json',
|
|
53
|
+
};
|
|
54
|
+
case 'array':
|
|
55
|
+
const values = migrateField(oldField.items);
|
|
56
|
+
if (!values) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
...metaParser(oldField),
|
|
61
|
+
type: 'array',
|
|
62
|
+
values,
|
|
63
|
+
};
|
|
64
|
+
case 'set':
|
|
65
|
+
return {
|
|
66
|
+
...metaParser(oldField),
|
|
67
|
+
type: 'set',
|
|
68
|
+
items: migrateField(oldField.items),
|
|
69
|
+
};
|
|
70
|
+
case 'record':
|
|
71
|
+
return {
|
|
72
|
+
...metaParser(oldField),
|
|
73
|
+
type: 'record',
|
|
74
|
+
values: migrateField(oldField.values),
|
|
75
|
+
};
|
|
76
|
+
case 'reference':
|
|
77
|
+
case 'references':
|
|
78
|
+
return {
|
|
79
|
+
...metaParser(oldField),
|
|
80
|
+
type: oldField.type,
|
|
81
|
+
...(oldField.bidirectional
|
|
82
|
+
? { bidirectional: oldField.bidirectional }
|
|
83
|
+
: null),
|
|
84
|
+
};
|
|
85
|
+
case 'float':
|
|
86
|
+
return {
|
|
87
|
+
...metaParser(oldField),
|
|
88
|
+
type: 'number',
|
|
89
|
+
};
|
|
90
|
+
case 'int':
|
|
91
|
+
return {
|
|
92
|
+
...metaParser(oldField),
|
|
93
|
+
type: 'integer',
|
|
94
|
+
};
|
|
95
|
+
case 'digest':
|
|
96
|
+
return {
|
|
97
|
+
...metaParser(oldField),
|
|
98
|
+
format: 'strongPassword',
|
|
99
|
+
type: 'string',
|
|
100
|
+
};
|
|
101
|
+
case 'id':
|
|
102
|
+
return {
|
|
103
|
+
format: 'basedId',
|
|
104
|
+
...metaParser(oldField),
|
|
105
|
+
type: 'string',
|
|
106
|
+
};
|
|
107
|
+
case 'url':
|
|
108
|
+
return {
|
|
109
|
+
...metaParser(oldField),
|
|
110
|
+
format: 'URL',
|
|
111
|
+
type: 'string',
|
|
112
|
+
};
|
|
113
|
+
case 'email':
|
|
114
|
+
return {
|
|
115
|
+
format: 'email',
|
|
116
|
+
...metaParser(oldField),
|
|
117
|
+
type: 'string',
|
|
118
|
+
};
|
|
119
|
+
case 'phone':
|
|
120
|
+
return {
|
|
121
|
+
...metaParser(oldField),
|
|
122
|
+
format: 'mobilePhone',
|
|
123
|
+
type: 'string',
|
|
124
|
+
};
|
|
125
|
+
case 'geo':
|
|
126
|
+
return {
|
|
127
|
+
...metaParser(oldField),
|
|
128
|
+
format: 'latLong',
|
|
129
|
+
type: 'string',
|
|
130
|
+
};
|
|
131
|
+
case 'type':
|
|
132
|
+
return {
|
|
133
|
+
...metaParser(oldField),
|
|
134
|
+
type: 'string',
|
|
135
|
+
};
|
|
136
|
+
case 'number':
|
|
137
|
+
return {
|
|
138
|
+
...metaParser(oldField),
|
|
139
|
+
type: 'number',
|
|
140
|
+
};
|
|
141
|
+
default:
|
|
142
|
+
return {
|
|
143
|
+
...metaParser(oldField),
|
|
144
|
+
type: oldField.type,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const migrateFields = (oldFields, recursing = false) => {
|
|
149
|
+
const result = {};
|
|
150
|
+
if (oldFields) {
|
|
151
|
+
for (const key in oldFields) {
|
|
152
|
+
if (true) {
|
|
153
|
+
if (!recursing && Object.keys(DEFAULT_FIELDS).includes(key)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const field = migrateField(oldFields[key]);
|
|
157
|
+
if (!field) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
result[key] = field;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
};
|
|
166
|
+
const migrateTypes = (oldSchema) => {
|
|
167
|
+
const result = {
|
|
168
|
+
types: {},
|
|
169
|
+
};
|
|
170
|
+
for (const key in oldSchema.types) {
|
|
171
|
+
if (oldSchema.types.hasOwnProperty(key)) {
|
|
172
|
+
const type = oldSchema.types[key];
|
|
173
|
+
result.types[key] = {
|
|
174
|
+
...metaParser(type),
|
|
175
|
+
prefix: type.prefix,
|
|
176
|
+
fields: migrateFields(type.fields),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
};
|
|
182
|
+
const convertRoot = (oldSchema) => {
|
|
183
|
+
const result = {
|
|
184
|
+
fields: {},
|
|
185
|
+
...metaParser(oldSchema.rootType?.meta),
|
|
186
|
+
...(oldSchema.rootType?.prefix
|
|
187
|
+
? { prefix: oldSchema.rootType.prefix }
|
|
188
|
+
: null),
|
|
189
|
+
};
|
|
190
|
+
for (const i in oldSchema.rootType?.fields) {
|
|
191
|
+
const field = oldSchema.rootType?.fields[i];
|
|
192
|
+
result.fields[i] = {
|
|
193
|
+
...metaParser(field?.meta),
|
|
194
|
+
...migrateField(field),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
};
|
|
199
|
+
export const convertOldToNew = (oldSchema) => {
|
|
200
|
+
const tempSchema = migrateTypes(oldSchema);
|
|
201
|
+
tempSchema.$defs = {};
|
|
202
|
+
tempSchema.language = oldSchema.languages[0];
|
|
203
|
+
tempSchema.prefixToTypeMapping = oldSchema.prefixToTypeMapping;
|
|
204
|
+
tempSchema.translations = oldSchema.languages.filter((_, i) => i !== 0);
|
|
205
|
+
tempSchema.root = convertRoot(oldSchema);
|
|
206
|
+
delete tempSchema.rootType;
|
|
207
|
+
delete tempSchema.sha;
|
|
208
|
+
return tempSchema;
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=oldToNew.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const basedSchemaNumberFormats: readonly [any, "short", "human", "ratio", "bytes", "euro", "dollar", "pound"];
|
|
2
|
+
export type NumberFormat = (typeof basedSchemaNumberFormats)[number] | `round-${number}`;
|
|
2
3
|
declare const parseNumber: (nr: number | string, format?: NumberFormat) => string | number;
|
|
3
4
|
export default parseNumber;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const basedSchemaDisplayFormats: readonly ["lowercase", "uppercase", "capitalize"];
|
|
2
|
+
export type basedSchemaDisplayFormat = (typeof basedSchemaDisplayFormats)[number];
|
|
3
|
+
export type StringFormat = basedSchemaDisplayFormat;
|
|
2
4
|
declare const parseString: (value?: string, format?: StringFormat) => string;
|
|
3
5
|
export default parseString;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const basedSchemaDateFormats: readonly [any, "date", "date-time", "date-time-text", "human", "time", "time-precise"];
|
|
2
|
+
export type BasedSchemaDateFormat = (typeof basedSchemaDateFormats)[number];
|
|
3
|
+
export type DateFormat = BasedSchemaDateFormat;
|
|
2
4
|
declare const _default: (nr: number | string, format?: DateFormat) => string | number;
|
|
3
5
|
export default _default;
|
package/dist/src/error.d.ts
CHANGED
|
@@ -15,5 +15,7 @@ export declare enum ParseError {
|
|
|
15
15
|
'noLanguageFound' = 13,
|
|
16
16
|
'cannotDeleteNodeFromModify' = 14,
|
|
17
17
|
'nestedModifyObjectNotAllowed' = 15,
|
|
18
|
-
'infinityNotSupported' = 16
|
|
18
|
+
'infinityNotSupported' = 16,
|
|
19
|
+
'invalidSchemaFormat' = 17,
|
|
20
|
+
'invalidProperty' = 18
|
|
19
21
|
}
|
package/dist/src/error.js
CHANGED
|
@@ -17,5 +17,7 @@ export var ParseError;
|
|
|
17
17
|
ParseError[ParseError["cannotDeleteNodeFromModify"] = 14] = "cannotDeleteNodeFromModify";
|
|
18
18
|
ParseError[ParseError["nestedModifyObjectNotAllowed"] = 15] = "nestedModifyObjectNotAllowed";
|
|
19
19
|
ParseError[ParseError["infinityNotSupported"] = 16] = "infinityNotSupported";
|
|
20
|
+
ParseError[ParseError["invalidSchemaFormat"] = 17] = "invalidSchemaFormat";
|
|
21
|
+
ParseError[ParseError["invalidProperty"] = 18] = "invalidProperty";
|
|
20
22
|
})(ParseError || (ParseError = {}));
|
|
21
23
|
//# sourceMappingURL=error.js.map
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './validateSchema.js';
|
|
2
|
+
export * from './validateSchema/index.js';
|
|
3
3
|
export * from './walker/index.js';
|
|
4
4
|
export * from './set/index.js';
|
|
5
5
|
export * from './display/index.js';
|
|
6
|
+
export * from './compat/index.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/src/types.d.ts
CHANGED
|
@@ -43,23 +43,25 @@ export type BasedSchemaFieldShared = {
|
|
|
43
43
|
};
|
|
44
44
|
$delete?: boolean;
|
|
45
45
|
};
|
|
46
|
+
export declare const basedSchemaStringFormatValues: readonly ["email", "URL", "MACAddress", "IP", "IPRange", "FQDN", "IBAN", "BIC", "alpha", "alphaLocales", "alphanumeric", "alphanumericLocales", "passportNumber", "port", "lowercase", "uppercase", "ascii", "semVer", "surrogatePair", "IMEI", "hexadecimal", "octal", "hexColor", "rgbColor", "HSL", "ISRC", "MD5", "JWT", "UUID", "luhnNumber", "creditCard", "identityCard", "EAN", "ISIN", "ISBN", "ISSN", "mobilePhone", "mobilePhoneLocales", "postalCode", "postalCodeLocales", "ethereumAddress", "currency", "btcAddress", "ISO6391", "ISO8601", "RFC3339", "ISO31661Alpha2", "ISO31661Alpha3", "ISO4217", "base32", "base58", "base64", "dataURI", "magnetURI", "mimeType", "latLong", "slug", "strongPassword", "taxID", "licensePlate", "VAT", "code", "typescript", "javascript", "python", "rust", "css", "html", "json", "markdown", "clike", "basedId"];
|
|
46
47
|
export type BasedSchemaStringShared = {
|
|
47
48
|
minLength?: number;
|
|
48
49
|
maxLength?: number;
|
|
49
50
|
contentMediaEncoding?: string;
|
|
50
51
|
contentMediaType?: BasedSchemaContentMediaType;
|
|
51
52
|
pattern?: BasedSchemaPattern;
|
|
52
|
-
format?:
|
|
53
|
+
format?: (typeof basedSchemaStringFormatValues)[number];
|
|
53
54
|
display?: StringFormat;
|
|
54
55
|
multiline?: boolean;
|
|
55
56
|
};
|
|
56
|
-
type
|
|
57
|
+
export type BasedSchemaNumberDefaults = {
|
|
57
58
|
multipleOf?: number;
|
|
58
59
|
minimum?: number;
|
|
59
60
|
maximum?: number;
|
|
60
61
|
exclusiveMaximum?: boolean;
|
|
61
62
|
exclusiveMinimum?: boolean;
|
|
62
63
|
};
|
|
64
|
+
export type NumberDefaults = BasedSchemaNumberDefaults;
|
|
63
65
|
export type BasedNumberDisplay = NumberFormat;
|
|
64
66
|
export type BasedTimestampDisplay = DateFormat;
|
|
65
67
|
export type BasedSchemaFieldString = {
|
|
@@ -209,4 +211,3 @@ export type BasedSchemaCollectProps = ArgsClass<BasedSetTarget> & {
|
|
|
209
211
|
typeSchema: BasedSchemaType;
|
|
210
212
|
};
|
|
211
213
|
};
|
|
212
|
-
export {};
|
package/dist/src/types.js
CHANGED
|
@@ -21,4 +21,78 @@ export const isCollection = (type) => {
|
|
|
21
21
|
return type === 'array' || type === 'object' || type === 'record';
|
|
22
22
|
};
|
|
23
23
|
export const languages = Object.keys(allLanguages);
|
|
24
|
+
export const basedSchemaStringFormatValues = [
|
|
25
|
+
'email',
|
|
26
|
+
'URL',
|
|
27
|
+
'MACAddress',
|
|
28
|
+
'IP',
|
|
29
|
+
'IPRange',
|
|
30
|
+
'FQDN',
|
|
31
|
+
'IBAN',
|
|
32
|
+
'BIC',
|
|
33
|
+
'alpha',
|
|
34
|
+
'alphaLocales',
|
|
35
|
+
'alphanumeric',
|
|
36
|
+
'alphanumericLocales',
|
|
37
|
+
'passportNumber',
|
|
38
|
+
'port',
|
|
39
|
+
'lowercase',
|
|
40
|
+
'uppercase',
|
|
41
|
+
'ascii',
|
|
42
|
+
'semVer',
|
|
43
|
+
'surrogatePair',
|
|
44
|
+
'IMEI',
|
|
45
|
+
'hexadecimal',
|
|
46
|
+
'octal',
|
|
47
|
+
'hexColor',
|
|
48
|
+
'rgbColor',
|
|
49
|
+
'HSL',
|
|
50
|
+
'ISRC',
|
|
51
|
+
'MD5',
|
|
52
|
+
'JWT',
|
|
53
|
+
'UUID',
|
|
54
|
+
'luhnNumber',
|
|
55
|
+
'creditCard',
|
|
56
|
+
'identityCard',
|
|
57
|
+
'EAN',
|
|
58
|
+
'ISIN',
|
|
59
|
+
'ISBN',
|
|
60
|
+
'ISSN',
|
|
61
|
+
'mobilePhone',
|
|
62
|
+
'mobilePhoneLocales',
|
|
63
|
+
'postalCode',
|
|
64
|
+
'postalCodeLocales',
|
|
65
|
+
'ethereumAddress',
|
|
66
|
+
'currency',
|
|
67
|
+
'btcAddress',
|
|
68
|
+
'ISO6391',
|
|
69
|
+
'ISO8601',
|
|
70
|
+
'RFC3339',
|
|
71
|
+
'ISO31661Alpha2',
|
|
72
|
+
'ISO31661Alpha3',
|
|
73
|
+
'ISO4217',
|
|
74
|
+
'base32',
|
|
75
|
+
'base58',
|
|
76
|
+
'base64',
|
|
77
|
+
'dataURI',
|
|
78
|
+
'magnetURI',
|
|
79
|
+
'mimeType',
|
|
80
|
+
'latLong',
|
|
81
|
+
'slug',
|
|
82
|
+
'strongPassword',
|
|
83
|
+
'taxID',
|
|
84
|
+
'licensePlate',
|
|
85
|
+
'VAT',
|
|
86
|
+
'code',
|
|
87
|
+
'typescript',
|
|
88
|
+
'javascript',
|
|
89
|
+
'python',
|
|
90
|
+
'rust',
|
|
91
|
+
'css',
|
|
92
|
+
'html',
|
|
93
|
+
'json',
|
|
94
|
+
'markdown',
|
|
95
|
+
'clike',
|
|
96
|
+
'basedId',
|
|
97
|
+
];
|
|
24
98
|
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { deepEqual } from '@saulx/utils';
|
|
2
|
+
import { ParseError } from '../error.js';
|
|
3
|
+
import { mustBeBoolean, mustBeString, mustBeStringArray } from './utils.js';
|
|
4
|
+
import { mustBeFields } from './fieldValidators.js';
|
|
5
|
+
export const basedSchemaTypeValidator = {
|
|
6
|
+
directory: {
|
|
7
|
+
validator: mustBeString,
|
|
8
|
+
optional: true,
|
|
9
|
+
},
|
|
10
|
+
fields: {
|
|
11
|
+
validator: mustBeFields,
|
|
12
|
+
},
|
|
13
|
+
title: {
|
|
14
|
+
validator: mustBeString,
|
|
15
|
+
optional: true,
|
|
16
|
+
},
|
|
17
|
+
description: {
|
|
18
|
+
validator: mustBeString,
|
|
19
|
+
optional: true,
|
|
20
|
+
},
|
|
21
|
+
prefix: {
|
|
22
|
+
validator: (value, path) => {
|
|
23
|
+
if (deepEqual(path, ['root', 'prefix'])) {
|
|
24
|
+
return value === 'ro'
|
|
25
|
+
? []
|
|
26
|
+
: [{ code: ParseError.incorrectFormat, path }];
|
|
27
|
+
}
|
|
28
|
+
return /^[a-z]{2}$/.test(value)
|
|
29
|
+
? []
|
|
30
|
+
: [{ code: ParseError.incorrectFormat, path }];
|
|
31
|
+
},
|
|
32
|
+
optional: true,
|
|
33
|
+
},
|
|
34
|
+
examples: { optional: true },
|
|
35
|
+
required: {
|
|
36
|
+
validator: mustBeStringArray,
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
$defs: { optional: true },
|
|
40
|
+
$delete: {
|
|
41
|
+
validator: mustBeBoolean,
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=basedSchemaTypeValidator.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BasedSchema, BasedSchemaFieldAny, BasedSchemaFieldArray, BasedSchemaFieldBoolean, BasedSchemaFieldCardinality, BasedSchemaFieldEnum, BasedSchemaFieldInteger, BasedSchemaFieldJSON, BasedSchemaFieldNumber, BasedSchemaFieldObject, BasedSchemaFieldRecord, BasedSchemaFieldReference, BasedSchemaFieldReferences, BasedSchemaFieldSet, BasedSchemaFieldShared, BasedSchemaFieldString, BasedSchemaFieldText, BasedSchemaFieldTimeStamp, BasedSchemaNumberDefaults, BasedSchemaPartial, BasedSchemaStringShared } from '../types.js';
|
|
2
|
+
import { ValidateSchemaError, Validator } from './index.js';
|
|
3
|
+
type MustBeFieldOptions = {
|
|
4
|
+
limitTo?: 'primitives' | 'enumerables';
|
|
5
|
+
};
|
|
6
|
+
export declare const mustBeField: (value: any, path: string[], newSchema: BasedSchemaPartial, oldSchema: BasedSchema, options?: MustBeFieldOptions) => ValidateSchemaError[];
|
|
7
|
+
export declare const mustBeFields: (value: any, path: string[], newSchema: BasedSchemaPartial, oldSchema: BasedSchema) => ValidateSchemaError[];
|
|
8
|
+
export declare const basedSchemaFieldSharedValidator: Validator<BasedSchemaFieldShared>;
|
|
9
|
+
export declare const basedSchemaStringSharedValidator: Validator<BasedSchemaStringShared>;
|
|
10
|
+
export declare const basedSchemaStringValidator: Validator<BasedSchemaFieldString>;
|
|
11
|
+
export declare const basedSchemaFieldEnumValidator: Validator<BasedSchemaFieldEnum>;
|
|
12
|
+
export declare const basedSchemaFieldCardinalityValidator: Validator<BasedSchemaFieldCardinality>;
|
|
13
|
+
export declare const basedSchemaNumberDefaultsValidator: Validator<BasedSchemaNumberDefaults>;
|
|
14
|
+
export declare const basedSchemaFieldNumberValidator: Validator<BasedSchemaFieldNumber>;
|
|
15
|
+
export declare const basedSchemaFieldIntegerValidator: Validator<BasedSchemaFieldInteger>;
|
|
16
|
+
export declare const basedSchemaFieldTimeStampValidator: Validator<BasedSchemaFieldTimeStamp>;
|
|
17
|
+
export declare const basedSchemaFieldBooleanValidator: Validator<BasedSchemaFieldBoolean>;
|
|
18
|
+
export declare const basedSchemaFieldJSONValidator: Validator<BasedSchemaFieldJSON>;
|
|
19
|
+
export declare const basedSchemaFieldAnyValidator: Validator<BasedSchemaFieldAny>;
|
|
20
|
+
export declare const basedSchemaFieldTextValidator: Validator<BasedSchemaFieldText>;
|
|
21
|
+
export declare const basedSchemaFieldObjectValidator: Validator<BasedSchemaFieldObject>;
|
|
22
|
+
export declare const basedSchemaFieldRecordValidator: Validator<BasedSchemaFieldRecord>;
|
|
23
|
+
export declare const basedSchemaFieldArrayValidator: Validator<BasedSchemaFieldArray>;
|
|
24
|
+
export declare const basedSchemaFieldSetValidator: Validator<BasedSchemaFieldSet>;
|
|
25
|
+
export declare const basedSchemaFieldReferenceValidator: Validator<BasedSchemaFieldReference>;
|
|
26
|
+
export declare const basedSchemaFieldReferencesValidator: Validator<BasedSchemaFieldReferences>;
|
|
27
|
+
export {};
|