Skip to content

Commit

Permalink
Fixed schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
AydanPirani committed Apr 20, 2024
1 parent 9b451b8 commit 4558a8a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
34 changes: 3 additions & 31 deletions src/services/attendees/attendee-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,23 @@ import { z } from "zod";

// Zod schema for attendee
const AttendeeValidator = z.object({
userId: z.string(),
name: z.string(),
email: z.string().email(),
studentInfo: z.object({
university: z.string().nonempty(),
graduation: z.string().nullable().optional(),
major: z.string().nullable().optional(),
}),
events: z.array(z.string()),
dietary_restrictions: z.string(),
age: z.number().nullable().optional(),
gender: z.string().nullable().optional(),
race: z.array(z.string()).nullable().optional(),
ethnicity: z.string().nullable().optional(),
first_gen: z.string().nullable().optional(),
hear_about_rp: z.array(z.string()).nullable().optional(),
portfolio: z.string().nullable().optional(),
job_interest: z.array(z.string()).nullable().optional(),
interest_mech_puzzle: z.array(z.string()).nullable().optional(),
priority_expiry: z.date().nullable().optional(),
has_resume: z.boolean().optional(),
points: z.number().min(0).default(0), //
points: z.number().min(0).default(0),
});

// Mongoose schema for attendee
const AttendeeSchema = new mongoose.Schema({
userId: { type: String, required: true, unique: true },
name: { type: String, required: true },
email: { type: String, required: true, unique: true },
studentInfo: {
university: { type: String, required: true },
graduation: { type: String, default: null },
major: { type: String, default: null },
},
events: [{ type: mongoose.Schema.Types.ObjectId, ref: "Event" }],
dietary_restrictions: { type: String, required: true },
age: { type: Number, default: null },
gender: { type: String, default: null },
race: [{ type: String }],
ethnicity: { type: String, default: null },
first_gen: { type: String, default: null },
hear_about_rp: [{ type: String }],
portfolio: { type: String, default: null },
job_interest: [{ type: String }],
interest_mech_puzzle: [{ type: String }],
priority_expiry: { type: Date, default: null },
has_resume: { type: Boolean, default: false },
points: { type: Number, default: 0 },
});

Expand Down
38 changes: 33 additions & 5 deletions src/services/registration/registration-schema.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
import mongoose from "mongoose";
import { z } from "zod";
import { boolean, z } from "zod";

Check failure on line 2 in src/services/registration/registration-schema.ts

View workflow job for this annotation

GitHub Actions / build

'boolean' is declared but its value is never read.

Check failure on line 2 in src/services/registration/registration-schema.ts

View workflow job for this annotation

GitHub Actions / lint

'boolean' is defined but never used

// Zod schema for registration
const RegistrationValidator = z.object({
userId: z.string(),
name: z.string(),
email: z.string().email(),
events: z.array(z.string()),
studentInfo: z.object({
university: z.string().nonempty(),
graduation: z.string().nullable().optional(),
major: z.string().nullable().optional(),
}),
dietary_restrictions: z.string(),
points: z.number().min(0).default(0),
age: z.number().nullable().optional(),
gender: z.string().nullable().optional(),
race: z.array(z.string()).nullable().optional(),
ethnicity: z.array(z.string()).nullable().optional(),
first_gen: z.string().nullable().optional(),
hear_about_rp: z.array(z.string()).nullable().optional(),
portfolio: z.string().nullable().optional(),
job_interest: z.array(z.string()).nullable().optional(),
interest_mech_puzzle: z.array(z.string()).nullable().optional(),
has_resume: z.boolean()

Check failure on line 24 in src/services/registration/registration-schema.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
});

// Mongoose schema for registration
const RegistrationSchema = new mongoose.Schema({
userId: {type: String, required: true, unique: true },

Check failure on line 29 in src/services/registration/registration-schema.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
name: { type: String, required: true },
email: { type: String, required: true, unique: true },
events: [{ type: mongoose.Schema.Types.ObjectId, ref: "Event" }],
studentInfo: {
university: { type: String, required: true },
graduation: { type: String, default: null },
major: { type: String, default: null },
},
dietary_restrictions: { type: String, required: true },
points: { type: Number, default: 0 },
age: { type: Number, default: null },
gender: { type: String, default: null },
race: [{ type: String }],
ethnicity: [{ type: String }],
first_gen: { type: String, default: null },
hear_about_rp: [{ type: String }],
portfolio: { type: String, default: null },
job_interest: [{ type: String }],
interest_mech_puzzle: [{ type: String }],

Check failure on line 46 in src/services/registration/registration-schema.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `····`
has_resume: { type: Boolean, default: false },
});

export { RegistrationSchema, RegistrationValidator };

0 comments on commit 4558a8a

Please sign in to comment.