use of teammates.common.util.FieldValidator in project teammates by TEAMMATES.
the class InstructorFeedbackAbstractAction method validateTimeData.
protected void validateTimeData(FeedbackSessionAttributes attributes) throws InvalidParametersException {
FieldValidator validator = new FieldValidator();
// Stop if invalid or fixed offset time zone is detected
String paramTimeZone = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_TIMEZONE);
String timeZoneErrorMessage = validator.getInvalidityInfoForTimeZone(paramTimeZone);
if (!timeZoneErrorMessage.isEmpty()) {
// Collect other errors before throwing an exception
List<String> errors = new ArrayList<>(attributes.getInvalidityInfo());
errors.add(timeZoneErrorMessage);
throw new InvalidParametersException(errors);
}
// The time zone is valid at this point and can be used for future calculations
ZoneId timeZone = attributes.getTimeZone();
// Warn if ambiguity of time fields (brought about by DST) is detected
validateLocalDateTimeUnambiguity(inputStartTimeLocal, attributes.getStartTime(), timeZone, FieldValidator.SESSION_START_TIME_FIELD_NAME);
validateLocalDateTimeUnambiguity(inputEndTimeLocal, attributes.getEndTime(), timeZone, FieldValidator.SESSION_END_TIME_FIELD_NAME);
validateLocalDateTimeUnambiguity(inputVisibleTimeLocal, attributes.getSessionVisibleFromTime(), timeZone, FieldValidator.SESSION_VISIBLE_TIME_FIELD_NAME);
validateLocalDateTimeUnambiguity(inputPublishTimeLocal, attributes.getResultsVisibleFromTime(), timeZone, FieldValidator.RESULTS_VISIBLE_TIME_FIELD_NAME);
}
use of teammates.common.util.FieldValidator in project teammates by TEAMMATES.
the class AdminEmailComposeSendAction method checkAddressReceiverString.
private void checkAddressReceiverString(String addressReceiverString) throws InvalidParametersException {
FieldValidator validator = new FieldValidator();
String[] emails = addressReceiverString.split(",");
for (String email : emails) {
String error = validator.getInvalidityInfoForEmail(email);
if (!error.isEmpty()) {
isError = true;
statusToUser.add(new StatusMessage(error, StatusMessageColor.DANGER));
throw new InvalidParametersException("<strong>Email Format Error</strong>");
}
}
}
use of teammates.common.util.FieldValidator in project teammates by TEAMMATES.
the class StudentAttributes method getInvalidityInfo.
@Override
public List<String> getInvalidityInfo() {
// id is allowed to be null when the student is not registered
Assumption.assertNotNull(team);
Assumption.assertNotNull(comments);
FieldValidator validator = new FieldValidator();
List<String> errors = new ArrayList<>();
if (isRegistered()) {
addNonEmptyError(validator.getInvalidityInfoForGoogleId(googleId), errors);
}
addNonEmptyError(validator.getInvalidityInfoForCourseId(course), errors);
addNonEmptyError(validator.getInvalidityInfoForEmail(email), errors);
addNonEmptyError(validator.getInvalidityInfoForTeamName(team), errors);
addNonEmptyError(validator.getInvalidityInfoForSectionName(section), errors);
addNonEmptyError(validator.getInvalidityInfoForStudentRoleComments(comments), errors);
addNonEmptyError(validator.getInvalidityInfoForPersonName(name), errors);
return errors;
}
use of teammates.common.util.FieldValidator in project teammates by TEAMMATES.
the class AdminEmailAttributes method getInvalidityInfo.
@Override
public List<String> getInvalidityInfo() {
FieldValidator validator = new FieldValidator();
List<String> errors = new ArrayList<>();
addNonEmptyError(validator.getInvalidityInfoForEmailContent(content), errors);
addNonEmptyError(validator.getInvalidityInfoForEmailSubject(subject), errors);
return errors;
}
use of teammates.common.util.FieldValidator in project teammates by TEAMMATES.
the class FeedbackQuestionAttributes method getInvalidityInfo.
@Override
public List<String> getInvalidityInfo() {
FieldValidator validator = new FieldValidator();
List<String> errors = new ArrayList<>();
addNonEmptyError(validator.getInvalidityInfoForFeedbackSessionName(feedbackSessionName), errors);
addNonEmptyError(validator.getInvalidityInfoForCourseId(courseId), errors);
// special case when additional text should be added to error text
String error = validator.getInvalidityInfoForEmail(creatorEmail);
if (!error.isEmpty()) {
error = new StringBuffer().append("Invalid creator's email: ").append(error).toString();
}
addNonEmptyError(error, errors);
errors.addAll(validator.getValidityInfoForFeedbackParticipantType(giverType, recipientType));
errors.addAll(validator.getValidityInfoForFeedbackResponseVisibility(showResponsesTo, showGiverNameTo, showRecipientNameTo));
return errors;
}
Aggregations