Skip to content

Commit 6ee82c1

Browse files
committed
test: add test for #14003
1 parent d8f94f9 commit 6ee82c1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

test/types/models.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,3 +751,11 @@ function gh13957() {
751751
const repository = new RepositoryBase<ITest>(TestModel);
752752
expectType<Promise<ITest[]>>(repository.insertMany([{ name: 'test' }]));
753753
}
754+
755+
async function gh14003() {
756+
const schema = new Schema({ name: String });
757+
const TestModel = model('Test', schema);
758+
759+
await TestModel.validate({ name: 'foo' }, ['name']);
760+
await TestModel.validate({ name: 'foo' }, { pathsToSkip: ['name'] });
761+
}

types/models.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,8 @@ declare module 'mongoose' {
462462
/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */
463463
validate(): Promise<void>;
464464
validate(obj: any): Promise<void>;
465-
validate(
466-
obj: any,
467-
pathsOrOptions: PathsToValidate | { pathsToSkip?: PathsToValidate }
468-
): Promise<void>;
465+
validate(obj: any, pathsOrOptions: PathsToValidate): Promise<void>;
466+
validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise<void>;
469467

470468
/** Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/). */
471469
watch<ResultType extends mongodb.Document = any, ChangeType extends mongodb.ChangeStreamDocument = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType, ChangeType>;

0 commit comments

Comments
 (0)