Я отправляю код ссылки, соответствующий этому, в противном случае Показать ваш код.
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const bcrypt = require("bcryptjs");
const jwt = require("jsonwebtoken");
const cryptoRandomString = require('crypto-random-string');
const userSchema = new Schema({
firstName: {
trim: true,
type: String,
required: [true, "firstName is required!"],
validate(value) {
if (value.length < 2) {
throw new Error("firstName is invalid!");
}
}
},
lastName: {
trim: true,
type: String,
required: [true, "lastName is required!"],
validate(value) {
if (value.length < 2) {
throw new Error("lastName is invalid!");
}
}
},
email: {
unique: [true, "Email already registered"],
type: String,
required: [true, "Email is required"]
},
mobile: {
unique: [true, "Mobile Number alraedy available"],
type: String,
required: [true, "Mobile Number is required"],
validate(value) {
if (value.length !== 10) {
throw new Error("Mobile Number is invalid!");
}
}
},
password: {
type: String,
required: [true, "Password is required"],
validate(value) {
if (value.length < 6) {
throw new Error("Password must be atleast 6 characters!");
}
}
}
});