Skip to content

Commit

Permalink
Changed regex to static string
Browse files Browse the repository at this point in the history
  • Loading branch information
rladdusaw committed May 13, 2020
1 parent 2c8fe9e commit a2a899f
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -6,20 +6,22 @@

public class ProductValidator extends BaseModelValidator {

private static final String URL_REGEX = "^(https?|ftp|file|wss?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]+[-a-zA-Z0-9+&@#/%=~_|?]";

public ProductValidator() {
String nameProperty = "name";
this.addInputValidator(new InputValidator(InputValidationType.required, "A Product requires a name", nameProperty, true));

String devUrlProperty = "devUrl";
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The development URL must be a valid URL", devUrlProperty, "^(https?|ftp|file|wss?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]+[-a-zA-Z0-9+&@#/%=~_|?]"));
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The development URL must be a valid URL", devUrlProperty, URL_REGEX));

String preUrlProperty = "preUrl";
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The pre-production URL must be a valid URL", preUrlProperty, "^(https?|ftp|file|wss?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]+[-a-zA-Z0-9+&@#/%=~_|?]"));
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The pre-production URL must be a valid URL", preUrlProperty, URL_REGEX));

String productionUrlProperty = "productionUrl";
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The production URL must be a valid URL", productionUrlProperty, "^(https?|ftp|file|wss?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]+[-a-zA-Z0-9+&@#/%=~_|?]"));
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The production URL must be a valid URL", productionUrlProperty, URL_REGEX));

String wikiUrlProperty = "wikiUrl";
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The wiki URL must be a valid URL", wikiUrlProperty, "^(https?|ftp|file|wss?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]+[-a-zA-Z0-9+&@#/%=~_|?]"));
this.addInputValidator(new InputValidator(InputValidationType.pattern, "The wiki URL must be a valid URL", wikiUrlProperty, URL_REGEX));
}
}

0 comments on commit a2a899f

Please sign in to comment.