Fixed the wrong UUID regex
it allowed more letters than it should fixes #302
This commit is contained in:
@@ -40,7 +40,7 @@ class RegexPatterns {
|
||||
protected static final Pattern HOSTNAME_PATTERN = Pattern.compile('((http[s]?|ftp):/)/?([^:/\\s]+)(:[0-9]{1,5})?')
|
||||
protected static final Pattern EMAIL = Pattern.compile('[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}')
|
||||
protected static final Pattern URL = UrlHelper.URL
|
||||
protected static final Pattern UUID = Pattern.compile('[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}')
|
||||
protected static final Pattern UUID = Pattern.compile('[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}')
|
||||
protected static final Pattern ANY_DATE = Pattern.compile('(\\d\\d\\d\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])')
|
||||
protected static final Pattern ANY_DATE_TIME = Pattern.compile('([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])')
|
||||
protected static final Pattern ANY_TIME = Pattern.compile('(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])')
|
||||
|
||||
@@ -143,12 +143,13 @@ class RegexPatternsSpec extends Specification {
|
||||
expect:
|
||||
shouldMatch == Pattern.compile(regexPatterns.uuid()).matcher(textToMatch).matches()
|
||||
where:
|
||||
textToMatch || shouldMatch
|
||||
UUID.randomUUID().toString() || true
|
||||
UUID.randomUUID().toString() || true
|
||||
UUID.randomUUID().toString() + "!" || false
|
||||
'dog' || false
|
||||
'5' || false
|
||||
textToMatch || shouldMatch
|
||||
UUID.randomUUID().toString() || true
|
||||
UUID.randomUUID().toString() || true
|
||||
UUID.randomUUID().toString() + "!" || false
|
||||
'23e4567-z89b-12z3-j456-426655440000' || false
|
||||
'dog' || false
|
||||
'5' || false
|
||||
}
|
||||
|
||||
def "should generate a regex with date [#textToMatch] in YYYY-MM-DD format that should match [#shouldMatch]"() {
|
||||
|
||||
Reference in New Issue
Block a user