Package org.motechproject.mots.validate
Class ValidationUtils
- java.lang.Object
-
- org.motechproject.mots.validate.ValidationUtils
-
public final class ValidationUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ValidationUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddDefaultViolationMessage(javax.validation.ConstraintValidatorContext context, java.lang.String message)Add the custom violation message as the error message.static voidaddDefaultViolationMessageToInnerField(javax.validation.ConstraintValidatorContext context, java.lang.String fieldName)Add the default violation message as the error message for a inner field.static voidaddDefaultViolationMessageToInnerField(javax.validation.ConstraintValidatorContext context, java.lang.String fieldName, java.lang.String message)Add the custom violation message as the error message for a inner field.static booleanisValidDateFormat(java.lang.String format, java.lang.String value)Validation of date format.static booleanisValidUuidString(java.lang.String string)static booleanmatchPattern(java.lang.String stringPattern, java.lang.String value)static booleanvalidateUuids(java.util.Collection<java.lang.String> values)Validation of uuids.
-
-
-
Method Detail
-
isValidUuidString
public static boolean isValidUuidString(java.lang.String string)
-
validateUuids
public static boolean validateUuids(java.util.Collection<java.lang.String> values)
Validation of uuids.- Parameters:
values- collection of uuids- Returns:
- true if all strings are valid UUIDs, false otherwise
-
isValidDateFormat
public static boolean isValidDateFormat(java.lang.String format, java.lang.String value)Validation of date format.- Parameters:
format- is the format of datevalue- is a date value to check- Returns:
- true if date is valid against given format
-
matchPattern
public static boolean matchPattern(java.lang.String stringPattern, java.lang.String value)
-
addDefaultViolationMessageToInnerField
public static void addDefaultViolationMessageToInnerField(javax.validation.ConstraintValidatorContext context, java.lang.String fieldName)Add the default violation message as the error message for a inner field.- Parameters:
context- is the validation contextfieldName- is a name of the field inner the object to which the annotation was applied
-
addDefaultViolationMessageToInnerField
public static void addDefaultViolationMessageToInnerField(javax.validation.ConstraintValidatorContext context, java.lang.String fieldName, java.lang.String message)Add the custom violation message as the error message for a inner field.- Parameters:
context- is the validation contextfieldName- is the name of the field inner the object to which the annotation was appliedmessage- is the violation message that will be reported as the error message
-
addDefaultViolationMessage
public static void addDefaultViolationMessage(javax.validation.ConstraintValidatorContext context, java.lang.String message)Add the custom violation message as the error message.- Parameters:
context- is the validation contextmessage- is the violation message that will be reported as the error message
-
-