Fixed the error when using optional() and anyOf() together

fixes gh-1215
This commit is contained in:
Marcin Grzejszczak
2019-11-08 14:57:48 +01:00
parent 22d7be7e96
commit 207617d4ce
2 changed files with 29 additions and 2 deletions

View File

@@ -45,8 +45,16 @@ class OptionalProperty implements Serializable, CanBeDynamic {
}
String value() {
return this.value instanceof RegexProperty ?
((RegexProperty) this.value).pattern.pattern() : this.value
Object valueToCheck = valueToCheck()
return (valueToCheck instanceof RegexProperty || valueToCheck instanceof Pattern) ?
new RegexProperty(valueToCheck).pattern.pattern() : valueToCheck
}
private Object valueToCheck() {
if (this.value instanceof ClientDslProperty) {
return ((ClientDslProperty) this.value).getClientValue()
}
return this.value
}
protected Pattern optionalPatternValue() {