
원두마켓
mongoose 에러 핸들링
Built-in Validator export const UserSchema = new Schema( { userId: { type: String, unique: true, required: true, match: /[a-z0-9_]{4,16}/, }, ... } ); mongoose Schema를 작성할 때, 각각의 field에 대해 validator를 지정할 수 있으며, 각각의 validator를 통과하지 못하면 에러를 발생시킨다. 이 때 Path `userId` is required가 오류 메시지이며, 이 오류 메시지를 Array Syntax로 간단하게 커스텀할 수 있다. export const UserSchema = new Schema( { userId: { type: String, unique:..