@Override
    public boolean isValid(final String value, final ConstraintValidatorContext context) {
        boolean result = true;

        if (value != null) {
            try {
                Pattern.compile(value);
            } catch (PatternSyntaxException e) {
                final String msgTemplate =
                        context.getDefaultConstraintMessageTemplate() +
                                ". caused by: " +
                                e.getMessage().replaceAll("\\n", " ");

                // We want the exception details in the message so bin the default constraint
                // violation and make a new one.
                context.disableDefaultConstraintViolation();
                context
                        .buildConstraintViolationWithTemplate(msgTemplate)
                        .addConstraintViolation();
                result = false;
            }
        }
        return result;
    }
Implements the validation logic.
The state of {@code value} must not be altered.
<p>
This method can be accessed concurrently, thread-safety must be ensured
by the implementation.

@param value   object to validate
@param context context in which the constraint is evaluated
@return {@code false} if {@code value} does not pass the constraint
stroom-util/src/main/java/stroom/util/validation/ValidRegexValidatorImpl.java