@bedrockio/model 0.12.3 → 0.13.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/CHANGELOG.md +11 -0
- package/README.md +6 -5
- package/dist/cjs/search.js +14 -0
- package/dist/cjs/validation.js +28 -30
- package/package.json +3 -3
- package/src/search.js +15 -0
- package/src/validation.js +54 -48
- package/types/search.d.ts +204 -0
- package/types/search.d.ts.map +1 -1
- package/types/validation-schemas.d.ts +2 -1
- package/types/validation-schemas.d.ts.map +1 -1
- package/types/validation.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 0.13.1
|
|
2
|
+
|
|
3
|
+
- Do not enforce unique constraints in search validation.
|
|
4
|
+
|
|
5
|
+
## 0.13.0
|
|
6
|
+
|
|
7
|
+
- Removed support for passing schemas into `getCreateValidation` etc. now that
|
|
8
|
+
other methods available on yada exist. Instead allow more flexibility in
|
|
9
|
+
schema options.
|
|
10
|
+
- Allow appending export schema as an option.
|
|
11
|
+
|
|
1
12
|
## 0.12.3
|
|
2
13
|
|
|
3
14
|
- Support for `include` with top level dynamic references.
|
package/README.md
CHANGED
|
@@ -456,8 +456,9 @@ validation which will:
|
|
|
456
456
|
- `Model.restoreMany`
|
|
457
457
|
- `Model.insertMany`
|
|
458
458
|
- `Model.replaceOne`
|
|
459
|
-
- Append the same validation to `Model.
|
|
460
|
-
`Model.
|
|
459
|
+
- Append the same validation to `Model.getCreateValidation` and
|
|
460
|
+
`Model.getUpdateValidation` to allow this constraint to trickle down to the
|
|
461
|
+
API.
|
|
461
462
|
|
|
462
463
|
> [!WARNING] Note that calling `Model.updateOne` will throw an error when a
|
|
463
464
|
> unique field exists on any document **including the document being updated**.
|
|
@@ -480,7 +481,7 @@ const router = new Router();
|
|
|
480
481
|
router.post(
|
|
481
482
|
'/',
|
|
482
483
|
validateBody(
|
|
483
|
-
User.getCreateValidation({
|
|
484
|
+
User.getCreateValidation().append({
|
|
484
485
|
password: yd.string().password().required(),
|
|
485
486
|
}),
|
|
486
487
|
),
|
|
@@ -547,7 +548,7 @@ new ones:
|
|
|
547
548
|
import yd from '@bedrockio/yada';
|
|
548
549
|
|
|
549
550
|
const signupSchema = yd.object({
|
|
550
|
-
...User.
|
|
551
|
+
...User.getCreateValidation().export(),
|
|
551
552
|
additionalField: yd.string().required(),
|
|
552
553
|
});
|
|
553
554
|
```
|
|
@@ -1290,7 +1291,7 @@ against scopes in the generated validations or when serializing:
|
|
|
1290
1291
|
|
|
1291
1292
|
```js
|
|
1292
1293
|
// In validation middleware:
|
|
1293
|
-
const schema = User.
|
|
1294
|
+
const schema = User.getCreateValidation();
|
|
1294
1295
|
await schema.validate(ctx.request.body, {
|
|
1295
1296
|
scopes: authUser.getScopes(),
|
|
1296
1297
|
// Also accepted:
|
package/dist/cjs/search.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applySearch = applySearch;
|
|
7
|
+
exports.exportValidation = exportValidation;
|
|
7
8
|
exports.searchValidation = searchValidation;
|
|
8
9
|
var _yada = _interopRequireDefault(require("@bedrockio/yada"));
|
|
9
10
|
var _logger = _interopRequireDefault(require("@bedrockio/logger"));
|
|
@@ -57,6 +58,19 @@ function searchValidation(options = {}) {
|
|
|
57
58
|
...appendSchema
|
|
58
59
|
});
|
|
59
60
|
}
|
|
61
|
+
function exportValidation(options = {}) {
|
|
62
|
+
const {
|
|
63
|
+
defaults,
|
|
64
|
+
formats = ['csv']
|
|
65
|
+
} = options;
|
|
66
|
+
const {
|
|
67
|
+
filename = 'export.csv'
|
|
68
|
+
} = defaults || {};
|
|
69
|
+
return {
|
|
70
|
+
filename: _yada.default.string().default(filename).description('Filename when search is exported.'),
|
|
71
|
+
format: _yada.default.string().allow('json', ...formats).default('json')
|
|
72
|
+
};
|
|
73
|
+
}
|
|
60
74
|
function searchQuery(Model, options, config) {
|
|
61
75
|
const {
|
|
62
76
|
schema
|
package/dist/cjs/validation.js
CHANGED
|
@@ -54,65 +54,67 @@ function addValidators(schemas) {
|
|
|
54
54
|
Object.assign(NAMED_SCHEMAS, schemas);
|
|
55
55
|
}
|
|
56
56
|
function applyValidation(schema, definition) {
|
|
57
|
-
schema.static('getCreateValidation', function getCreateValidation(options
|
|
58
|
-
const {
|
|
59
|
-
allowInclude,
|
|
60
|
-
...appendSchema
|
|
61
|
-
} = options;
|
|
57
|
+
schema.static('getCreateValidation', function getCreateValidation(options) {
|
|
62
58
|
return getSchemaFromMongoose(schema, {
|
|
63
59
|
model: this,
|
|
64
|
-
appendSchema,
|
|
65
|
-
allowInclude,
|
|
66
60
|
stripEmpty: true,
|
|
61
|
+
applyUnique: true,
|
|
67
62
|
stripDeleted: true,
|
|
63
|
+
allowInclude: false,
|
|
68
64
|
stripTimestamps: true,
|
|
69
65
|
allowDefaultTags: true,
|
|
70
66
|
allowExpandedRefs: true,
|
|
71
|
-
requireWriteAccess: true
|
|
67
|
+
requireWriteAccess: true,
|
|
68
|
+
...options
|
|
72
69
|
});
|
|
73
70
|
});
|
|
74
|
-
schema.static('getUpdateValidation', function getUpdateValidation(options
|
|
75
|
-
const {
|
|
76
|
-
allowInclude,
|
|
77
|
-
...appendSchema
|
|
78
|
-
} = options;
|
|
71
|
+
schema.static('getUpdateValidation', function getUpdateValidation(options) {
|
|
79
72
|
return getSchemaFromMongoose(schema, {
|
|
80
73
|
model: this,
|
|
81
|
-
appendSchema,
|
|
82
|
-
allowInclude,
|
|
83
74
|
allowNull: true,
|
|
75
|
+
applyUnique: true,
|
|
84
76
|
skipRequired: true,
|
|
85
77
|
stripUnknown: true,
|
|
86
78
|
stripDeleted: true,
|
|
79
|
+
allowInclude: false,
|
|
87
80
|
stripTimestamps: true,
|
|
88
81
|
allowExpandedRefs: true,
|
|
89
82
|
requireWriteAccess: true,
|
|
90
|
-
updateAccess: definition.access?.update
|
|
83
|
+
updateAccess: definition.access?.update,
|
|
84
|
+
...options
|
|
91
85
|
});
|
|
92
86
|
});
|
|
93
87
|
schema.static('getSearchValidation', function getSearchValidation(options = {}) {
|
|
94
88
|
const {
|
|
89
|
+
allowExport,
|
|
95
90
|
defaults,
|
|
96
|
-
|
|
97
|
-
...
|
|
91
|
+
formats,
|
|
92
|
+
...rest
|
|
98
93
|
} = options;
|
|
99
|
-
|
|
94
|
+
let validation = getSchemaFromMongoose(schema, {
|
|
100
95
|
model: this,
|
|
101
96
|
allowNull: true,
|
|
102
97
|
stripEmpty: true,
|
|
103
98
|
allowSearch: true,
|
|
104
99
|
skipRequired: true,
|
|
105
100
|
allowInclude: true,
|
|
101
|
+
stripDeleted: true,
|
|
106
102
|
expandDotSyntax: true,
|
|
107
103
|
unwindArrayFields: true,
|
|
108
104
|
requireReadAccess: true,
|
|
109
|
-
|
|
110
|
-
appendSchema: (0, _search.searchValidation)({
|
|
111
|
-
defaults,
|
|
112
|
-
definition,
|
|
113
|
-
appendSchema
|
|
114
|
-
})
|
|
105
|
+
...rest
|
|
115
106
|
});
|
|
107
|
+
validation = validation.append((0, _search.searchValidation)({
|
|
108
|
+
defaults,
|
|
109
|
+
definition
|
|
110
|
+
}));
|
|
111
|
+
if (allowExport) {
|
|
112
|
+
validation = validation.append((0, _search.exportValidation)({
|
|
113
|
+
formats,
|
|
114
|
+
defaults
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
return validation;
|
|
116
118
|
});
|
|
117
119
|
schema.static('getDeleteValidation', function getDeleteValidation() {
|
|
118
120
|
const allowed = definition.access?.delete || 'all';
|
|
@@ -157,14 +159,10 @@ function getMongooseFields(schema, options) {
|
|
|
157
159
|
// Exported for testing
|
|
158
160
|
function getValidationSchema(attributes, options = {}) {
|
|
159
161
|
const {
|
|
160
|
-
appendSchema,
|
|
161
162
|
allowInclude,
|
|
162
163
|
updateAccess
|
|
163
164
|
} = options;
|
|
164
165
|
let schema = getObjectSchema(attributes, options);
|
|
165
|
-
if (appendSchema) {
|
|
166
|
-
schema = schema.append(appendSchema);
|
|
167
|
-
}
|
|
168
166
|
if (allowInclude) {
|
|
169
167
|
schema = schema.append(_include.INCLUDE_FIELD_SCHEMA);
|
|
170
168
|
}
|
|
@@ -308,7 +306,7 @@ function getSchemaForTypedef(typedef, options = {}) {
|
|
|
308
306
|
if (typedef.writeAccess && options.requireWriteAccess) {
|
|
309
307
|
schema = validateAccess('write', schema, typedef.writeAccess, options);
|
|
310
308
|
}
|
|
311
|
-
if (typedef.softUnique) {
|
|
309
|
+
if (typedef.softUnique && options.applyUnique) {
|
|
312
310
|
schema = schema.custom(async (value, {
|
|
313
311
|
path,
|
|
314
312
|
originalRoot
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrockio/model",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Bedrock utilities for model creation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lodash": "^4.17.21"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@bedrockio/yada": "^1.
|
|
33
|
+
"@bedrockio/yada": "^1.5.0",
|
|
34
34
|
"mongoose": "^8.13.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.26.0",
|
|
40
40
|
"@bedrockio/eslint-plugin": "^1.1.7",
|
|
41
41
|
"@bedrockio/prettier-config": "^1.0.2",
|
|
42
|
-
"@bedrockio/yada": "^1.
|
|
42
|
+
"@bedrockio/yada": "^1.5.0",
|
|
43
43
|
"@shelf/jest-mongodb": "^5.1.0",
|
|
44
44
|
"eslint": "^9.19.0",
|
|
45
45
|
"jest": "^29.7.0",
|
package/src/search.js
CHANGED
|
@@ -63,6 +63,21 @@ export function searchValidation(options = {}) {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
export function exportValidation(options = {}) {
|
|
67
|
+
const { defaults, formats = ['csv'] } = options;
|
|
68
|
+
const { filename = 'export.csv' } = defaults || {};
|
|
69
|
+
return {
|
|
70
|
+
filename: yd
|
|
71
|
+
.string()
|
|
72
|
+
.default(filename)
|
|
73
|
+
.description('Filename when search is exported.'),
|
|
74
|
+
format: yd
|
|
75
|
+
.string()
|
|
76
|
+
.allow('json', ...formats)
|
|
77
|
+
.default('json'),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
66
81
|
function searchQuery(Model, options, config) {
|
|
67
82
|
const { schema } = Model;
|
|
68
83
|
|
package/src/validation.js
CHANGED
|
@@ -4,7 +4,7 @@ import yd from '@bedrockio/yada';
|
|
|
4
4
|
import { get, omit, lowerFirst } from 'lodash';
|
|
5
5
|
|
|
6
6
|
import { hasAccess } from './access';
|
|
7
|
-
import { searchValidation } from './search';
|
|
7
|
+
import { searchValidation, exportValidation } from './search';
|
|
8
8
|
import { assertUnique } from './soft-delete';
|
|
9
9
|
import { PermissionsError, ImplementationError } from './errors';
|
|
10
10
|
import { isMongooseSchema, isSchemaTypedef } from './utils';
|
|
@@ -56,65 +56,74 @@ export function addValidators(schemas) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export function applyValidation(schema, definition) {
|
|
59
|
-
schema.static(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
);
|
|
59
|
+
schema.static('getCreateValidation', function getCreateValidation(options) {
|
|
60
|
+
return getSchemaFromMongoose(schema, {
|
|
61
|
+
model: this,
|
|
62
|
+
stripEmpty: true,
|
|
63
|
+
applyUnique: true,
|
|
64
|
+
stripDeleted: true,
|
|
65
|
+
allowInclude: false,
|
|
66
|
+
stripTimestamps: true,
|
|
67
|
+
allowDefaultTags: true,
|
|
68
|
+
allowExpandedRefs: true,
|
|
69
|
+
requireWriteAccess: true,
|
|
70
|
+
...options,
|
|
71
|
+
});
|
|
72
|
+
});
|
|
76
73
|
|
|
77
|
-
schema.static(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
);
|
|
74
|
+
schema.static('getUpdateValidation', function getUpdateValidation(options) {
|
|
75
|
+
return getSchemaFromMongoose(schema, {
|
|
76
|
+
model: this,
|
|
77
|
+
allowNull: true,
|
|
78
|
+
applyUnique: true,
|
|
79
|
+
skipRequired: true,
|
|
80
|
+
stripUnknown: true,
|
|
81
|
+
stripDeleted: true,
|
|
82
|
+
allowInclude: false,
|
|
83
|
+
stripTimestamps: true,
|
|
84
|
+
allowExpandedRefs: true,
|
|
85
|
+
requireWriteAccess: true,
|
|
86
|
+
updateAccess: definition.access?.update,
|
|
87
|
+
...options,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
96
90
|
|
|
97
91
|
schema.static(
|
|
98
92
|
'getSearchValidation',
|
|
99
93
|
function getSearchValidation(options = {}) {
|
|
100
|
-
const { defaults,
|
|
101
|
-
|
|
94
|
+
const { allowExport, defaults, formats, ...rest } = options;
|
|
95
|
+
|
|
96
|
+
let validation = getSchemaFromMongoose(schema, {
|
|
102
97
|
model: this,
|
|
103
98
|
allowNull: true,
|
|
104
99
|
stripEmpty: true,
|
|
105
100
|
allowSearch: true,
|
|
106
101
|
skipRequired: true,
|
|
107
102
|
allowInclude: true,
|
|
103
|
+
stripDeleted: true,
|
|
108
104
|
expandDotSyntax: true,
|
|
109
105
|
unwindArrayFields: true,
|
|
110
106
|
requireReadAccess: true,
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
...rest,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
validation = validation.append(
|
|
111
|
+
searchValidation({
|
|
113
112
|
defaults,
|
|
114
113
|
definition,
|
|
115
|
-
appendSchema,
|
|
116
114
|
}),
|
|
117
|
-
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
if (allowExport) {
|
|
118
|
+
validation = validation.append(
|
|
119
|
+
exportValidation({
|
|
120
|
+
formats,
|
|
121
|
+
defaults,
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return validation;
|
|
118
127
|
},
|
|
119
128
|
);
|
|
120
129
|
|
|
@@ -160,13 +169,10 @@ function getMongooseFields(schema, options) {
|
|
|
160
169
|
|
|
161
170
|
// Exported for testing
|
|
162
171
|
export function getValidationSchema(attributes, options = {}) {
|
|
163
|
-
const {
|
|
172
|
+
const { allowInclude, updateAccess } = options;
|
|
164
173
|
|
|
165
174
|
let schema = getObjectSchema(attributes, options);
|
|
166
175
|
|
|
167
|
-
if (appendSchema) {
|
|
168
|
-
schema = schema.append(appendSchema);
|
|
169
|
-
}
|
|
170
176
|
if (allowInclude) {
|
|
171
177
|
schema = schema.append(INCLUDE_FIELD_SCHEMA);
|
|
172
178
|
}
|
|
@@ -322,7 +328,7 @@ function getSchemaForTypedef(typedef, options = {}) {
|
|
|
322
328
|
schema = validateAccess('write', schema, typedef.writeAccess, options);
|
|
323
329
|
}
|
|
324
330
|
|
|
325
|
-
if (typedef.softUnique) {
|
|
331
|
+
if (typedef.softUnique && options.applyUnique) {
|
|
326
332
|
schema = schema.custom(async (value, { path, originalRoot }) => {
|
|
327
333
|
const { id } = originalRoot;
|
|
328
334
|
await assertUnique({
|
package/types/search.d.ts
CHANGED
|
@@ -49,4 +49,208 @@ export function searchValidation(options?: {}): {
|
|
|
49
49
|
runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
|
|
50
50
|
enumToOpenApi(): any;
|
|
51
51
|
};
|
|
52
|
+
export function exportValidation(options?: {}): {
|
|
53
|
+
filename: {
|
|
54
|
+
required(): /*elided*/ any;
|
|
55
|
+
length(length: number): /*elided*/ any;
|
|
56
|
+
min(length: number): /*elided*/ any;
|
|
57
|
+
max(length: number): /*elided*/ any;
|
|
58
|
+
trim(): /*elided*/ any;
|
|
59
|
+
lowercase(assert?: boolean): /*elided*/ any;
|
|
60
|
+
uppercase(assert?: boolean): /*elided*/ any;
|
|
61
|
+
match(reg: RegExp): /*elided*/ any;
|
|
62
|
+
email(): /*elided*/ any;
|
|
63
|
+
phone(code: any): /*elided*/ any;
|
|
64
|
+
hex(): /*elided*/ any;
|
|
65
|
+
md5(): /*elided*/ any;
|
|
66
|
+
sha1(): /*elided*/ any;
|
|
67
|
+
ascii(): /*elided*/ any;
|
|
68
|
+
base64(options?: {
|
|
69
|
+
urlSafe?: boolean;
|
|
70
|
+
}): /*elided*/ any;
|
|
71
|
+
creditCard(): /*elided*/ any;
|
|
72
|
+
ip(): /*elided*/ any;
|
|
73
|
+
country(): /*elided*/ any;
|
|
74
|
+
locale(): /*elided*/ any;
|
|
75
|
+
jwt(): /*elided*/ any;
|
|
76
|
+
slug(): /*elided*/ any;
|
|
77
|
+
latlng(): /*elided*/ any;
|
|
78
|
+
postalCode(locale?: string): /*elided*/ any;
|
|
79
|
+
zipcode(): /*elided*/ any;
|
|
80
|
+
password(options?: {
|
|
81
|
+
minLength?: number;
|
|
82
|
+
minNumbers?: number;
|
|
83
|
+
minSymbols?: number;
|
|
84
|
+
minLowercase?: number;
|
|
85
|
+
minUppercase?: number;
|
|
86
|
+
}): /*elided*/ any;
|
|
87
|
+
url(options?: {
|
|
88
|
+
require_protocol?: boolean;
|
|
89
|
+
require_valid_protocol?: boolean;
|
|
90
|
+
require_host?: boolean;
|
|
91
|
+
require_port?: boolean;
|
|
92
|
+
allow_protocol_relative_urls?: boolean;
|
|
93
|
+
allow_fragments?: boolean;
|
|
94
|
+
allow_query_components?: boolean;
|
|
95
|
+
validate_length?: boolean;
|
|
96
|
+
protocols?: string[];
|
|
97
|
+
}): /*elided*/ any;
|
|
98
|
+
domain(options?: {
|
|
99
|
+
require_tld?: boolean;
|
|
100
|
+
allow_underscores?: boolean;
|
|
101
|
+
allow_trailing_dot?: boolean;
|
|
102
|
+
allow_numeric_tld?: boolean;
|
|
103
|
+
allow_wildcard?: boolean;
|
|
104
|
+
ignore_max_length?: boolean;
|
|
105
|
+
}): /*elided*/ any;
|
|
106
|
+
uuid(version?: 1 | 2 | 3 | 4 | 5): /*elided*/ any;
|
|
107
|
+
btc(): /*elided*/ any;
|
|
108
|
+
eth(): /*elided*/ any;
|
|
109
|
+
swift(): /*elided*/ any;
|
|
110
|
+
mongo(): /*elided*/ any;
|
|
111
|
+
calendar(): /*elided*/ any;
|
|
112
|
+
format(name: any, fn: any): /*elided*/ any;
|
|
113
|
+
toString(): any;
|
|
114
|
+
assertions: any[];
|
|
115
|
+
meta: {};
|
|
116
|
+
default(arg: any): /*elided*/ any;
|
|
117
|
+
custom(fn: Function): /*elided*/ any;
|
|
118
|
+
missing(fn: Function): /*elided*/ any;
|
|
119
|
+
strip(strip: any): /*elided*/ any;
|
|
120
|
+
allow(...set: any[]): /*elided*/ any;
|
|
121
|
+
reject(...set: any[]): /*elided*/ any;
|
|
122
|
+
nullable(): /*elided*/ any;
|
|
123
|
+
message(message: any): /*elided*/ any;
|
|
124
|
+
tag(tags: any): /*elided*/ any;
|
|
125
|
+
description(description: any): /*elided*/ any;
|
|
126
|
+
options(options: any): /*elided*/ any;
|
|
127
|
+
validate(value: any, options?: {}): Promise<any>;
|
|
128
|
+
clone(meta: any): /*elided*/ any;
|
|
129
|
+
append(schema: any): import("@bedrockio/yada/types/Schema").default;
|
|
130
|
+
toOpenApi(extra: any): any;
|
|
131
|
+
getAnyType(): {
|
|
132
|
+
type: string[];
|
|
133
|
+
};
|
|
134
|
+
getDefault(): {
|
|
135
|
+
default?: undefined;
|
|
136
|
+
} | {
|
|
137
|
+
default: any;
|
|
138
|
+
};
|
|
139
|
+
getNullable(): {
|
|
140
|
+
nullable: boolean;
|
|
141
|
+
};
|
|
142
|
+
expandExtra(extra?: {}): {};
|
|
143
|
+
inspect(): string;
|
|
144
|
+
get(): void;
|
|
145
|
+
assertEnum(set: any, allow: any): /*elided*/ any;
|
|
146
|
+
assert(type: any, fn: any): /*elided*/ any;
|
|
147
|
+
pushAssertion(assertion: any): void;
|
|
148
|
+
canSkipAssertion(value: any, assertion: any, options: any): any;
|
|
149
|
+
transform(fn: any): /*elided*/ any;
|
|
150
|
+
getSortIndex(type: any): number;
|
|
151
|
+
runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
|
|
152
|
+
enumToOpenApi(): any;
|
|
153
|
+
};
|
|
154
|
+
format: {
|
|
155
|
+
required(): /*elided*/ any;
|
|
156
|
+
length(length: number): /*elided*/ any;
|
|
157
|
+
min(length: number): /*elided*/ any;
|
|
158
|
+
max(length: number): /*elided*/ any;
|
|
159
|
+
trim(): /*elided*/ any;
|
|
160
|
+
lowercase(assert?: boolean): /*elided*/ any;
|
|
161
|
+
uppercase(assert?: boolean): /*elided*/ any;
|
|
162
|
+
match(reg: RegExp): /*elided*/ any;
|
|
163
|
+
email(): /*elided*/ any;
|
|
164
|
+
phone(code: any): /*elided*/ any;
|
|
165
|
+
hex(): /*elided*/ any;
|
|
166
|
+
md5(): /*elided*/ any;
|
|
167
|
+
sha1(): /*elided*/ any;
|
|
168
|
+
ascii(): /*elided*/ any;
|
|
169
|
+
base64(options?: {
|
|
170
|
+
urlSafe?: boolean;
|
|
171
|
+
}): /*elided*/ any;
|
|
172
|
+
creditCard(): /*elided*/ any;
|
|
173
|
+
ip(): /*elided*/ any;
|
|
174
|
+
country(): /*elided*/ any;
|
|
175
|
+
locale(): /*elided*/ any;
|
|
176
|
+
jwt(): /*elided*/ any;
|
|
177
|
+
slug(): /*elided*/ any;
|
|
178
|
+
latlng(): /*elided*/ any;
|
|
179
|
+
postalCode(locale?: string): /*elided*/ any;
|
|
180
|
+
zipcode(): /*elided*/ any;
|
|
181
|
+
password(options?: {
|
|
182
|
+
minLength?: number;
|
|
183
|
+
minNumbers?: number;
|
|
184
|
+
minSymbols?: number;
|
|
185
|
+
minLowercase?: number;
|
|
186
|
+
minUppercase?: number;
|
|
187
|
+
}): /*elided*/ any;
|
|
188
|
+
url(options?: {
|
|
189
|
+
require_protocol?: boolean;
|
|
190
|
+
require_valid_protocol?: boolean;
|
|
191
|
+
require_host?: boolean;
|
|
192
|
+
require_port?: boolean;
|
|
193
|
+
allow_protocol_relative_urls?: boolean;
|
|
194
|
+
allow_fragments?: boolean;
|
|
195
|
+
allow_query_components?: boolean;
|
|
196
|
+
validate_length?: boolean;
|
|
197
|
+
protocols?: string[];
|
|
198
|
+
}): /*elided*/ any;
|
|
199
|
+
domain(options?: {
|
|
200
|
+
require_tld?: boolean;
|
|
201
|
+
allow_underscores?: boolean;
|
|
202
|
+
allow_trailing_dot?: boolean;
|
|
203
|
+
allow_numeric_tld?: boolean;
|
|
204
|
+
allow_wildcard?: boolean;
|
|
205
|
+
ignore_max_length?: boolean;
|
|
206
|
+
}): /*elided*/ any;
|
|
207
|
+
uuid(version?: 1 | 2 | 3 | 4 | 5): /*elided*/ any;
|
|
208
|
+
btc(): /*elided*/ any;
|
|
209
|
+
eth(): /*elided*/ any;
|
|
210
|
+
swift(): /*elided*/ any;
|
|
211
|
+
mongo(): /*elided*/ any;
|
|
212
|
+
calendar(): /*elided*/ any;
|
|
213
|
+
format(name: any, fn: any): /*elided*/ any;
|
|
214
|
+
toString(): any;
|
|
215
|
+
assertions: any[];
|
|
216
|
+
meta: {};
|
|
217
|
+
default(arg: any): /*elided*/ any;
|
|
218
|
+
custom(fn: Function): /*elided*/ any;
|
|
219
|
+
missing(fn: Function): /*elided*/ any;
|
|
220
|
+
strip(strip: any): /*elided*/ any;
|
|
221
|
+
allow(...set: any[]): /*elided*/ any;
|
|
222
|
+
reject(...set: any[]): /*elided*/ any;
|
|
223
|
+
nullable(): /*elided*/ any;
|
|
224
|
+
message(message: any): /*elided*/ any;
|
|
225
|
+
tag(tags: any): /*elided*/ any;
|
|
226
|
+
description(description: any): /*elided*/ any;
|
|
227
|
+
options(options: any): /*elided*/ any;
|
|
228
|
+
validate(value: any, options?: {}): Promise<any>;
|
|
229
|
+
clone(meta: any): /*elided*/ any;
|
|
230
|
+
append(schema: any): import("@bedrockio/yada/types/Schema").default;
|
|
231
|
+
toOpenApi(extra: any): any;
|
|
232
|
+
getAnyType(): {
|
|
233
|
+
type: string[];
|
|
234
|
+
};
|
|
235
|
+
getDefault(): {
|
|
236
|
+
default?: undefined;
|
|
237
|
+
} | {
|
|
238
|
+
default: any;
|
|
239
|
+
};
|
|
240
|
+
getNullable(): {
|
|
241
|
+
nullable: boolean;
|
|
242
|
+
};
|
|
243
|
+
expandExtra(extra?: {}): {};
|
|
244
|
+
inspect(): string;
|
|
245
|
+
get(): void;
|
|
246
|
+
assertEnum(set: any, allow: any): /*elided*/ any;
|
|
247
|
+
assert(type: any, fn: any): /*elided*/ any;
|
|
248
|
+
pushAssertion(assertion: any): void;
|
|
249
|
+
canSkipAssertion(value: any, assertion: any, options: any): any;
|
|
250
|
+
transform(fn: any): /*elided*/ any;
|
|
251
|
+
getSortIndex(type: any): number;
|
|
252
|
+
runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
|
|
253
|
+
enumToOpenApi(): any;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
52
256
|
//# sourceMappingURL=search.d.ts.map
|
package/types/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAuBA,gEAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAuBA,gEAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA0CyC,CAAC;;;;;;;;;;;;;;;;;EAjBzC;AAED;;;;;;;;;;;;;;;;;mBAtBI,CAAA;;;;;;;;;;;;qBAuBC,CAAC;sBAA4B,CAAC;sBACvB,CAAC;wBAA8B,CAAC;wBAEnC,CAAC;;;4BA2BK,CAAC;kCACwB,CAAC;wBACrC,CAAA;wBAA+B,CAAC;wCAK9B,CAAJ;2BAAkC,CAAC;kCACP,CAAC;2BAIhB,CAAC;qBAA4B,CAAC;;;uBAsBT,CAAC;6BACH,CAAC;8BAI7B,CAAF;6BAAoC,CAAC;0BAClB,CAAC;6BAIhB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA5DiC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBArCtC,CAAA;;;;;;;;;;;;qBAuBC,CAAC;sBAA4B,CAAC;sBACvB,CAAC;wBAA8B,CAAC;wBAEnC,CAAC;;;4BA2BK,CAAC;kCACwB,CAAC;wBACrC,CAAA;wBAA+B,CAAC;wCAK9B,CAAJ;2BAAkC,CAAC;kCACP,CAAC;2BAIhB,CAAC;qBAA4B,CAAC;;;uBAsBT,CAAC;6BACH,CAAC;8BAI7B,CAAF;6BAAoC,CAAC;0BAClB,CAAC;6BAIhB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA5DiC,CAAC;;;;;;;;;;;;;;;;;;;EAFzC"}
|
|
@@ -5,7 +5,7 @@ export const DATE_SCHEMA: {
|
|
|
5
5
|
after(min: string | number | Date): /*elided*/ any;
|
|
6
6
|
past(): /*elided*/ any;
|
|
7
7
|
future(): /*elided*/ any;
|
|
8
|
-
iso(
|
|
8
|
+
iso(): /*elided*/ any;
|
|
9
9
|
timestamp(): /*elided*/ any;
|
|
10
10
|
unix(): /*elided*/ any;
|
|
11
11
|
assertions: any[];
|
|
@@ -107,6 +107,7 @@ export const OBJECT_ID_SCHEMA: {
|
|
|
107
107
|
eth(): /*elided*/ any;
|
|
108
108
|
swift(): /*elided*/ any;
|
|
109
109
|
mongo(): /*elided*/ any;
|
|
110
|
+
calendar(): /*elided*/ any;
|
|
110
111
|
format(name: any, fn: any): /*elided*/ any;
|
|
111
112
|
toString(): any;
|
|
112
113
|
assertions: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-schemas.d.ts","sourceRoot":"","sources":["../src/validation-schemas.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAoEI,CAAA;;;;;;;;;;;;;;;;;;EApEsD;AAE1D;;;;;;;;;;;;;;;;eAyBwB,CAAC;;;;;;;;;;;;iBAuBjB,CAAA;kBAA4B,CAAC;kBAEjC,CAAF;oBAEI,CAAC;oBAEI,CAAC;;;wBA2BC,CAAC;8BAGI,CAAC;oBAA+B,CAAC;oBAE1C,CAAC;oCAEL,CAAC;uBAAkC,CAAC;8BAAyC,CAAC;uBACzD,CAAC;iBAA4B,CAAC;;;mBAG0V,CAAC;yBAAoC,CAAC;0BAAqC,CAAC;yBAAoC,CAAC;sBAAiC,CAAC;yBAAoC,CAAC
|
|
1
|
+
{"version":3,"file":"validation-schemas.d.ts","sourceRoot":"","sources":["../src/validation-schemas.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAoEI,CAAA;;;;;;;;;;;;;;;;;;EApEsD;AAE1D;;;;;;;;;;;;;;;;eAyBwB,CAAC;;;;;;;;;;;;iBAuBjB,CAAA;kBAA4B,CAAC;kBAEjC,CAAF;oBAEI,CAAC;oBAEI,CAAC;;;wBA2BC,CAAC;8BAGI,CAAC;oBAA+B,CAAC;oBAE1C,CAAC;oCAEL,CAAC;uBAAkC,CAAC;8BAAyC,CAAC;uBACzD,CAAC;iBAA4B,CAAC;;;mBAG0V,CAAC;yBAAoC,CAAC;0BAAqC,CAAC;yBAAoC,CAAC;sBAAiC,CAAC;yBAAoC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA1BtkB,CAAA;;;;;;;;;;;;;;;;;;EA1DC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAwDI,CAAA;;;;;;;;;;;;;;;;;EA9CC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4CI,CAAA;;;;;;;;;;;;;;;;;EAlCC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgCI,CAAA;;;;;;;;;;;;;;;;;EAEC;AAEL,8EAqBK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,oEA2FC;AAsBD,wEAiBC;AA8SD;;;EAEC;AAED;;;EAOC"}
|