Class LongStringValidator
java.lang.Object
jp.ecuacion.lib.core.jakartavalidation.validator.LongStringValidator
- All Implemented Interfaces:
jakarta.validation.ConstraintValidator<LongString, String>
public class LongStringValidator
extends Object
implements jakarta.validation.ConstraintValidator<LongString, String>
Provides the validation logic for
LongString.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinitialize(LongString constraintAnnotation) Initializes an instance.booleanChecks if a string is convertible toLong.
-
Constructor Details
-
LongStringValidator
public LongStringValidator()Constructs a new instance.
-
-
Method Details
-
initialize
Initializes an instance.- Specified by:
initializein interfacejakarta.validation.ConstraintValidator<LongString, String>
-
isValid
Checks if a string is convertible toLong.a string is valid if the value is blank or Long.valueOf() does not throw exception.
comma-separated value is acceptable. This validator removes comma before check. This does not check the positions of the commas are correct.
Valid strings are: "
123", "123,456", "12,3,4,56"nullis valid following to the specification of Jakarta EE.empty ("")is also valid.
Blank is allowed because it's supposed to be used for fields in record, which accepts values from external. HTML (and maybe others) cannot tell difference between blank and null for number values. Otherwise we also want the information whether the empty value is submitted (=blank) or not (=null).- Specified by:
isValidin interfacejakarta.validation.ConstraintValidator<LongString, String>
-