Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Getters for IBANValidator's RegexValidator its patterns #29

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public Validator(String cc, int len, String format) {
this.lengthOfIBAN = len;
this.validator = new RegexValidator(format);
}

/**
* Getter method for validator.
*
* @return the {@link RegexValidator} for this validator.
*/
public RegexValidator getRegexValidator() {
return validator;
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ public RegexValidator(String[] regexs, boolean caseSensitive) {
}
}

/**
* Getter method for <code>patterns</code>.
*
* @return the array of <code>patterns</code> used to validate values.
*/
public Pattern[] getPatterns() {
return patterns;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method must return a copy of the the patterns otherwise the caller can mutate the array.

}

/**
* Validate a value against the set of regular expressions.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ public void testGetValidator() {
assertNull("gb", VALIDATOR.getValidator("gb"));
}

@Test
public void testGetRegexValidator() {
assertNotNull("GB", VALIDATOR.getValidator("GB").getRegexValidator());
assertNull("gb", VALIDATOR.getValidator("gb"));
}

@Test(expected=IllegalStateException.class)
public void testSetDefaultValidator1() {
assertNotNull(VALIDATOR.setValidator("GB", 15, "GB"));
Expand Down