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

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