Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
lutece
lutece-form-plugin-forms
Commits
d12b7074
Commit
d12b7074
authored
Dec 02, 2021
by
Guillaume Lépine
Browse files
FORMS-722: Fix Pattern validator
parent
0b1dc3b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/java/fr/paris/lutece/plugins/forms/validation/AbstractPatternValidator.java
View file @
d12b7074
...
...
@@ -37,6 +37,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
fr.paris.lutece.plugins.forms.business.Control
;
...
...
@@ -112,15 +113,19 @@ public abstract class AbstractPatternValidator extends AbstractValidator
if
(
regularExpression
!=
null
)
{
IRegularExpressionService
service
=
SpringContextService
.
getBean
(
BEAN_NAME_REGULAR_EXPRESSION
);
if
(
CollectionUtils
.
isEmpty
(
questionResponse
.
getEntryResponse
(
)
)
)
{
return
!
questionResponse
.
getQuestion
(
).
getEntry
(
).
isMandatory
(
);
}
for
(
Response
response
:
questionResponse
.
getEntryResponse
(
)
)
{
String
toValidate
=
getValueToValidate
(
response
);
if
(
StringUtils
.
isNotEmpty
(
toValidate
)
)
if
(
StringUtils
.
isNotEmpty
(
toValidate
)
&&
!
service
.
isMatches
(
toValidate
,
regularExpression
)
)
{
return
service
.
isMatches
(
toValidate
,
regularExpression
)
;
return
false
;
}
}
return
!
questionResponse
.
getQuestion
(
).
getEntry
(
).
isMandatory
(
)
;
return
true
;
}
return
false
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment