diff --git a/website/server/libs/baseModel.js b/website/server/libs/baseModel.js index e2a0e6700b..544eba8f77 100644 --- a/website/server/libs/baseModel.js +++ b/website/server/libs/baseModel.js @@ -12,7 +12,7 @@ export default function baseModel (schema, options = {}) { _id: { $type: String, default: uuid, - validate: [v => validator.isUUID(v), 'Invalid uuid.'], + validate: [v => validator.isUUID(v), 'Invalid uuid in baseModel.'], }, }); } diff --git a/website/server/models/challenge.js b/website/server/models/challenge.js index 5f37c3aa9e..c73693922a 100644 --- a/website/server/models/challenge.js +++ b/website/server/models/challenge.js @@ -32,10 +32,10 @@ const schema = new Schema({ rewards: [{ $type: String, ref: 'Task' }], }, leader: { - $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true, + $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for challenge leader.'], required: true, }, group: { - $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true, + $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid for challenge group.'], required: true, }, memberCount: { $type: Number, default: 0 }, prize: { $type: Number, default: 0, min: 0 }, diff --git a/website/server/models/group.js b/website/server/models/group.js index de9704c4ea..4078ee0a5a 100644 --- a/website/server/models/group.js +++ b/website/server/models/group.js @@ -77,7 +77,7 @@ export const schema = new Schema({ summary: { $type: String, maxlength: MAX_SUMMARY_SIZE_FOR_GUILDS }, description: String, leader: { - $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true, + $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for group leader.'], required: true, }, type: { $type: String, enum: ['guild', 'party'], required: true }, privacy: { diff --git a/website/server/models/iapPurchaseReceipt.js b/website/server/models/iapPurchaseReceipt.js index b06b3e090a..be8a1eece6 100644 --- a/website/server/models/iapPurchaseReceipt.js +++ b/website/server/models/iapPurchaseReceipt.js @@ -8,7 +8,7 @@ export const schema = new Schema({ _id: { $type: String, required: true }, // Use a custom string as _id consumed: { $type: Boolean, default: false, required: true }, userId: { - $type: String, ref: 'User', required: true, validate: [v => validator.isUUID(v), 'Invalid uuid.'], + $type: String, ref: 'User', required: true, validate: [v => validator.isUUID(v), 'Invalid uuid for iapPurchaseReceipt.'], }, }, { strict: true, diff --git a/website/server/models/subscriptionPlan.js b/website/server/models/subscriptionPlan.js index d59e10b14f..127b89935a 100644 --- a/website/server/models/subscriptionPlan.js +++ b/website/server/models/subscriptionPlan.js @@ -5,7 +5,7 @@ import baseModel from '../libs/baseModel'; export const schema = new mongoose.Schema({ planId: String, subscriptionId: String, - owner: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }, + owner: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for subscription owner.'] }, quantity: { $type: Number, default: 1 }, paymentMethod: String, // enum: ['Paypal', 'Stripe', 'Gift', 'Amazon Payments', 'Google', '']} customerId: String, // Billing Agreement Id in case of Amazon Payments diff --git a/website/server/models/tag.js b/website/server/models/tag.js index 270472dd24..1fa8bc59a7 100644 --- a/website/server/models/tag.js +++ b/website/server/models/tag.js @@ -9,7 +9,7 @@ export const schema = new Schema({ id: { $type: String, default: uuid, - validate: [v => validator.isUUID(v), 'Invalid uuid.'], + validate: [v => validator.isUUID(v), 'Invalid uuid for tag.'], required: true, }, name: { $type: String, required: true }, diff --git a/website/server/models/task.js b/website/server/models/task.js index 5c336b89fa..9e78834796 100644 --- a/website/server/models/task.js +++ b/website/server/models/task.js @@ -40,7 +40,7 @@ export const taskIsGroupOrChallengeQuery = { const reminderSchema = new Schema({ _id: false, id: { - $type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true, + $type: String, validate: [v => validator.isUUID(v), 'Invalid uuid for task reminder.'], default: shared.uuid, required: true, }, startDate: { $type: Date }, time: { $type: Date, required: true }, @@ -93,7 +93,7 @@ export const TaskSchema = new Schema({ }, tags: [{ $type: String, - validate: [v => validator.isUUID(v), 'Invalid uuid.'], + validate: [v => validator.isUUID(v), 'Invalid uuid for task tags.'], }], // redness or cost for rewards Required because it must be settable (for rewards) value: { $type: Number, default: 0, required: true }, @@ -107,27 +107,27 @@ export const TaskSchema = new Schema({ ], }, attribute: { $type: String, default: 'str', enum: ['str', 'con', 'int', 'per'] }, - userId: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }, // When not set it belongs to a challenge + userId: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for task owner.'] }, // When not set it belongs to a challenge challenge: { shortName: { $type: String }, - id: { $type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }, // When set (and userId not set) it's the original task - taskId: { $type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }, // When not set but challenge.id defined it's the original task + id: { $type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid for task challenge.'] }, // When set (and userId not set) it's the original task + taskId: { $type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid for task challenge task.'] }, // When not set but challenge.id defined it's the original task broken: { $type: String, enum: ['CHALLENGE_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED', 'CHALLENGE_CLOSED', 'CHALLENGE_TASK_NOT_FOUND'] }, // CHALLENGE_TASK_NOT_FOUND comes from v3 migration winner: String, // user.profile.name of the winner }, group: { - id: { $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }, + id: { $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid for task group.'] }, broken: { $type: String, enum: ['GROUP_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED'] }, - assignedUsers: [{ $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }], + assignedUsers: [{ $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for task group user.'] }], assignedDate: { $type: Date }, - taskId: { $type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }, + taskId: { $type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid for task group task.'] }, approval: { required: { $type: Boolean, default: false }, approved: { $type: Boolean, default: false }, dateApproved: { $type: Date }, - approvingUser: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }, + approvingUser: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid task group approvingUser.'] }, requested: { $type: Boolean, default: false }, requestedDate: { $type: Date }, }, @@ -292,7 +292,7 @@ const dailyTodoSchema = () => ({ text: { $type: String, required: false, default: '' }, // required:false because it can be empty on creation _id: false, id: { - $type: String, default: shared.uuid, required: true, validate: [v => validator.isUUID(v), 'Invalid uuid.'], + $type: String, default: shared.uuid, required: true, validate: [v => validator.isUUID(v), 'Invalid uuid for task checklist item.'], }, linkId: { $type: String }, }], diff --git a/website/server/models/user/schema.js b/website/server/models/user/schema.js index b8a7cffe05..11dfe555bb 100644 --- a/website/server/models/user/schema.js +++ b/website/server/models/user/schema.js @@ -404,7 +404,7 @@ export default new Schema({ default: () => ({}), }, - challenges: [{ $type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }], + challenges: [{ $type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid for user challenges.'] }], invitations: { // Using an array without validation because otherwise mongoose @@ -424,7 +424,7 @@ export default new Schema({ $type: String, ref: 'Group', required: true, - validate: [v => validator.isUUID(v), 'Invalid uuid.'], + validate: [v => validator.isUUID(v), 'Invalid uuid for user invitation party id.'], }, name: { $type: String, @@ -434,15 +434,15 @@ export default new Schema({ $type: String, ref: 'User', required: true, - validate: [v => validator.isUUID(v), 'Invalid uuid.'], + validate: [v => validator.isUUID(v), 'Invalid uuid for user invitation inviter id.'], }, }], }, - guilds: [{ $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }], + guilds: [{ $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid for user guild.'] }], party: { - _id: { $type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], ref: 'Group' }, + _id: { $type: String, validate: [v => validator.isUUID(v), 'Invalid uuid for user party.'], ref: 'Group' }, order: { $type: String, default: 'level' }, orderAscending: { $type: String, default: 'ascending' }, quest: { diff --git a/website/server/models/userNotification.js b/website/server/models/userNotification.js index 27d1c21953..6e28ed2777 100644 --- a/website/server/models/userNotification.js +++ b/website/server/models/userNotification.js @@ -59,7 +59,7 @@ export const schema = new Schema({ id: { $type: String, default: uuid, - validate: [v => validator.isUUID(v), 'Invalid uuid.'], + validate: [v => validator.isUUID(v), 'Invalid uuid for userNotification.'], // @TODO: Add these back once we figure out the issue with notifications // See Fix for https://github.com/HabitRPG/habitica/issues/9923 // required: true,