Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/types/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1634,3 +1634,7 @@ function gh14825() {
type SchemaType = InferSchemaType<typeof schema>;
expectAssignable<User>({} as SchemaType);
}

function gh14879() {
Schema.Types.String.setters.push((val?: unknown) => typeof val === 'string' ? val.trim() : val);
}
3 changes: 3 additions & 0 deletions types/schematypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ declare module 'mongoose' {
/** Attaches a getter for all instances of this schema type. */
static get(getter: (value: any) => any): void;

/** Array containing default setters for all instances of this SchemaType */
static setters: ((val?: unknown, priorVal?: unknown, doc?: Document<unknown>, options?: Record<string, any> | null) => unknown)[];

/** The class that Mongoose uses internally to instantiate this SchemaType's `options` property. */
OptionsConstructor: SchemaTypeOptions<T>;

Expand Down