Skip to content

validation updates #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/common/challenge-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ class ChallengeHelper {
await ensureAcessibilityToModifiedGroups(currentUser, data, challenge);
}

// Ensure descriptionFormat is either 'markdown' or 'html'
if (data.descriptionFormat && !_.includes(["markdown", "html"], data.descriptionFormat)) {
throw new errors.BadRequestError("The property 'descriptionFormat' must be either 'markdown' or 'html'");
}

// Ensure unchangeable fields are not changed
if (
_.get(challenge, "legacy.track") &&
Expand Down
5 changes: 5 additions & 0 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,11 @@ async function updateChallenge(currentUser, challengeId, data) {
_.set(data, "billing.markup", markup || 0);
}

// Make sure the user cannot change the direct project ID
if (data.legacy && data.legacy.directProjectId) {
_.unset(data, "legacy.directProjectId", directProjectId);
}

/* BEGIN self-service stuffs */

// TODO: At some point in the future this should be moved to a Self-Service Challenge Helper
Expand Down