From ddba06cca302a5c42b8c21c4487760f6337b7704 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Tue, 31 Oct 2017 21:01:23 +0100 Subject: [PATCH] support more languages --- .../java/com/sismics/rest/util/ValidationUtil.java | 13 ++++++------- .../docs/rest/resource/DocumentResource.java | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java b/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java index a9ecfb8e..ce4b9883 100644 --- a/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java +++ b/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java @@ -1,15 +1,14 @@ package com.sismics.rest.util; +import com.google.common.base.Strings; +import com.sismics.rest.exception.ClientException; +import org.apache.commons.lang.StringUtils; +import org.joda.time.DateTime; + import java.text.MessageFormat; import java.util.Date; import java.util.regex.Pattern; -import org.apache.commons.lang.StringUtils; -import org.joda.time.DateTime; - -import com.google.common.base.Strings; -import com.sismics.rest.exception.ClientException; - /** * Utility class to validate parameters. * @@ -58,7 +57,7 @@ public class ValidationUtil { throw new ClientException("ValidationError", MessageFormat.format("{0} must be more than {1} characters", name, lengthMin)); } if (lengthMax != null && s.length() > lengthMax) { - throw new ClientException("ValidationError", MessageFormat.format("{0} must be more than {1} characters", name, lengthMax)); + throw new ClientException("ValidationError", MessageFormat.format("{0} must be less than {1} characters", name, lengthMax)); } return s; } diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java index 45650b8d..2d6cda61 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java @@ -574,7 +574,7 @@ public class DocumentResource extends BaseResource { // Validate input data title = ValidationUtil.validateLength(title, "title", 1, 100, false); - language = ValidationUtil.validateLength(language, "language", 3, 3, false); + language = ValidationUtil.validateLength(language, "language", 3, 7, false); description = ValidationUtil.validateLength(description, "description", 0, 4000, true); subject = ValidationUtil.validateLength(subject, "subject", 0, 500, true); identifier = ValidationUtil.validateLength(identifier, "identifier", 0, 500, true);