Skip to content

Commit

Permalink
Merge pull request #120 from TogetherCrew/bugfix/user-validation
Browse files Browse the repository at this point in the history
[BUGFIX]
  • Loading branch information
cyri113 authored Oct 20, 2023
2 parents 4db45c0 + d5de431 commit f23904c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
5 changes: 0 additions & 5 deletions __tests__/unit/models/user.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ describe('User model', () => {
test('should correctly validate a valid user', async () => {
await expect(new User(user).validate()).resolves.toBeUndefined();
});

test('should throw a validation error if email is invalid', async () => {
user.email = 'invalidEmail';
await expect(new User(user).validate()).rejects.toThrow();
});
});

// describe('Cascade deletes', () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@togethercrew.dev/db",
"version": "3.0.11",
"version": "3.0.12",
"description": "All interactions with DB",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
5 changes: 0 additions & 5 deletions src/models/schemas/User.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Schema, type Document } from 'mongoose';
import validator from 'validator';
import { toJSON, paginate } from './plugins';
import { Community } from '../index';
import { type IUser, type UserModel } from '../../interfaces';
Expand All @@ -15,10 +14,6 @@ const userSchema = new Schema<IUser, UserModel>(
type: String,
trim: true,
lowercase: true,
validate(value: string) {
if (!validator.isEmail(value)) throw new Error('Email Address is not valid');
},
unique: true,
},
communities: [
{
Expand Down

0 comments on commit f23904c

Please sign in to comment.