We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The current validate type in @types/mongoose/index.d.ts is:
validate?: RegExp | [RegExp, string] | SchemaTypeOpts.ValidateFn<T> | [SchemaTypeOpts.ValidateFn<T>, string] | SchemaTypeOpts.ValidateOpts | SchemaTypeOpts.AsyncValidateOpts | SchemaTypeOpts.AsyncPromiseValidationFn<T> | SchemaTypeOpts.AsyncPromiseValidationOpts | (SchemaTypeOpts.ValidateOpts | SchemaTypeOpts.AsyncValidateOpts | SchemaTypeOpts.AsyncPromiseValidationFn<T> | SchemaTypeOpts.AsyncPromiseValidationOpts)[];
Here is the definition where you can give the validation message: [SchemaTypeOpts.ValidateFn, string] it is synchronous only
can you add somthing like [SchemaTypeOpts.AsyncPromiseValidationFn, string]
so it will be possible to write (using async):
const TestSchema = new Schema({ user : { type: Schema.Types.ObjectId, ref: 'User', validate: [ async function(value){ return UserSchema.findOne({_id: value}) != null; }, `User doesn't exist.` ] } }
Thanks in advance
The text was updated successfully, but these errors were encountered:
mongoose currently dosnt make offical typescript types, you should open a new issue in https://github.com/DefinitelyTyped/DefinitelyTyped/issues
reference: #8108
Sorry, something went wrong.
No branches or pull requests
The current validate type in @types/mongoose/index.d.ts is:
Here is the definition where you can give the validation message:
[SchemaTypeOpts.ValidateFn, string] it is synchronous only
can you add somthing like [SchemaTypeOpts.AsyncPromiseValidationFn, string]
so it will be possible to write (using async):
Thanks in advance
The text was updated successfully, but these errors were encountered: