ofuks commented on a change in pull request #588: [Dlab-1422] The endpoint URL 
verification
URL: https://github.com/apache/incubator-dlab/pull/588#discussion_r378992612
 
 

 ##########
 File path: 
services/self-service/src/main/java/com/epam/dlab/backendapi/domain/EndpointDTO.java
 ##########
 @@ -23,14 +23,27 @@
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
+import org.hibernate.validator.constraints.URL;
+import javax.validation.constraints.Pattern;
 
 
 @Data
 @JsonIgnoreProperties(ignoreUnknown = true)
 public class EndpointDTO {
-
+       /*
+         the URL_REGEXP_VALIDATION constant is a template for URL pattern,
+         i.e for url verification like "https://localhost:8084/a/$-*^.oLeh;/";
+        */
+       private static final String URL_REGEXP_VALIDATION = 
"^(http(s)?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
+    /*
+      the NAME_REGEXP_VALIDATION - regexp accepts the latin literals and 
arabic numbers, plus @._ symbols,
+      i.e the loc!a1 field name will be ignored
+    */
+    private static final String NAME_REGEXP_VALIDATION = "[a-zA-Z0-9@_.]+";
+       private static final String IMPROPER_FIELD_MESSAGE = "endpoint field is 
in improper format!";
+       @Pattern(regexp = NAME_REGEXP_VALIDATION, message = 
IMPROPER_FIELD_MESSAGE)
        private final String name;
-
+       @URL(regexp = URL_REGEXP_VALIDATION, message = IMPROPER_FIELD_MESSAGE)
 
 Review comment:
   I wonder ** IMPROPER_FIELD_MESSAGE** goes here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to