clarify all "Invalid uuid" messages by making each unique

This commit is contained in:
Alys
2020-01-29 15:49:55 +10:00
parent 02d6b77a03
commit 82a5bc236f
9 changed files with 23 additions and 23 deletions

View File

@@ -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.'],
},
});
}

View File

@@ -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 },

View File

@@ -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: {

View File

@@ -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,

View File

@@ -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

View File

@@ -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 },

View File

@@ -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 },
}],

View File

@@ -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: {

View File

@@ -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,