mongoose 8.2.3 → 8.3.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/browser.umd.js +1 -1
- package/lib/document.js +141 -56
- package/lib/model.js +13 -2
- package/lib/query.js +11 -3
- package/lib/schema/documentArray.js +2 -2
- package/lib/schema.js +8 -4
- package/lib/schemaType.js +18 -1
- package/package.json +11 -11
- package/types/index.d.ts +6 -32
- package/types/indexes.d.ts +2 -0
- package/types/middlewares.d.ts +5 -4
- package/types/models.d.ts +1 -1
- package/types/query.d.ts +6 -3
- package/types/schemaoptions.d.ts +1 -1
- package/types/schematypes.d.ts +10 -3
package/types/schematypes.d.ts
CHANGED
|
@@ -192,10 +192,14 @@ declare module 'mongoose' {
|
|
|
192
192
|
[other: string]: any;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
interface Validator {
|
|
196
|
-
message?: string;
|
|
195
|
+
interface Validator<DocType = any> {
|
|
196
|
+
message?: string;
|
|
197
|
+
type?: string;
|
|
198
|
+
validator?: ValidatorFunction<DocType>;
|
|
197
199
|
}
|
|
198
200
|
|
|
201
|
+
type ValidatorFunction<DocType = any> = (this: DocType, value: any, validatorProperties?: Validator) => any;
|
|
202
|
+
|
|
199
203
|
class SchemaType<T = any, DocType = any> {
|
|
200
204
|
/** SchemaType constructor */
|
|
201
205
|
constructor(path: string, options?: AnyObject, instance?: string);
|
|
@@ -281,7 +285,10 @@ declare module 'mongoose' {
|
|
|
281
285
|
validators: Validator[];
|
|
282
286
|
|
|
283
287
|
/** Adds validator(s) for this document path. */
|
|
284
|
-
validate(obj: RegExp |
|
|
288
|
+
validate(obj: RegExp | ValidatorFunction<DocType> | Validator<DocType>, errorMsg?: string, type?: string): this;
|
|
289
|
+
|
|
290
|
+
/** Adds multiple validators for this document path. */
|
|
291
|
+
validateAll(validators: Array<RegExp | ValidatorFunction<DocType> | Validator<DocType>>): this;
|
|
285
292
|
|
|
286
293
|
/** Default options for this SchemaType */
|
|
287
294
|
defaultOptions?: Record<string, any>;
|