Commit 0f08045d authored by Kevin Robert's avatar Kevin Robert
Browse files

Mise en place de l'ancienne regex pour la validation de la référence des réponses.

parent e9d8806a
......@@ -30,7 +30,7 @@ public class Choice {
public void validate() {
this.value = this.value.trim();
ValidationUtils.validateReference(this.value);
ValidationUtils.validateReferenceAnswer(this.value);
}
public String getLabel() {
......
......@@ -8,6 +8,7 @@ import com.unantes.orientactive.web.rest.errors.InvalidReferenceException;
public class ValidationUtils {
public static Pattern PATTERN_REFERENCE = Pattern.compile("^[a-zA-Z]+[a-zA-Z0-9_]*$");
public static Pattern PATTERN_REFERENCE_ANSWERS = Pattern.compile("^[a-zA-Z0-9_]*$");
public static String RESERVED_SEPARATOR = "__";
public static void validateReference(final String reference) {
......@@ -16,4 +17,11 @@ public class ValidationUtils {
throw new InvalidReferenceException();
}
}
public static void validateReferenceAnswer(final String reference) {
Matcher matcher = PATTERN_REFERENCE_ANSWERS.matcher(reference);
if (!matcher.matches() || reference.contains(RESERVED_SEPARATOR)) {
throw new InvalidReferenceException();
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment