Class ValidationSupport
- java.lang.Object
-
- com.broadleafcommerce.customer.service.validation.support.ValidationSupport
-
public final class ValidationSupport extends Object
Utility class containing reusable convenience methods for validation.- Author:
- Samarth Dhruva (samarthd), Chris Kittrell (ckittrell)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
validateAllPermissionsHaveIdAndName(Collection<AccountPermissionRef> permissionRefs, org.springframework.validation.Errors errors, String permissionsFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode)
This validation serves purely to guarantee that each reference has an id and name.static void
validateAllPermissionsNonNullAndHaveId(Collection<AccountPermissionRef> permissionRefs, org.springframework.validation.Errors errors, String permissionsFieldNameOnParent, String nullPermissionErrorCode, String missingIdErrorCode)
This validation serves purely to guarantee that each reference is not null and has an id.static void
validateAllRolesHaveIdAndName(Collection<AccountRoleRef> roleRefs, org.springframework.validation.Errors errors, String rolesFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode)
This validation serves purely to guarantee that each reference has an id and name.static void
validateAllRolesNonNullAndHaveId(Collection<AccountRoleRef> roleRefs, org.springframework.validation.Errors errors, String rolesFieldNameOnParent, String nullRoleErrorCode, String missingIdErrorCode)
This validation serves purely to guarantee that each reference is not null and has an id.
-
-
-
Method Detail
-
validateAllPermissionsHaveIdAndName
public static void validateAllPermissionsHaveIdAndName(Collection<AccountPermissionRef> permissionRefs, org.springframework.validation.Errors errors, String permissionsFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode)
This validation serves purely to guarantee that each reference has an id and name.This should be called when validating a parent object that references the given permissions.
- Parameters:
permissionRefs
- the collection of permissions to validateerrors
- the errors bound to the parent object being validatedpermissionsFieldNameOnParent
- the name of the field holding thesepermissionRefs
, which will be supplied toErrors.rejectValue(String, String, String)
if an error is encounteredmissingIdErrorCode
- the error code to set when a permission is found without an id. Can be a message key.missingNameErrorCode
- the error code to set when a permission is found without a name. Can be a message key.
-
validateAllPermissionsNonNullAndHaveId
public static void validateAllPermissionsNonNullAndHaveId(Collection<AccountPermissionRef> permissionRefs, org.springframework.validation.Errors errors, String permissionsFieldNameOnParent, String nullPermissionErrorCode, String missingIdErrorCode)
This validation serves purely to guarantee that each reference is not null and has an id.This should be called when validating a parent object that references the given permissions.
- Parameters:
permissionRefs
- the collection of permissions to validateerrors
- the errors bound to the parent object being validatedpermissionsFieldNameOnParent
- the name of the field holding thesepermissionRefs
, which will be supplied toErrors.rejectValue(String, String, String)
if an error is encounterednullPermissionErrorCode
- the error code to set when a null permission is found. Can be a message key.missingIdErrorCode
- the error code to set when a permission is found without an id. Can be a message key.
-
validateAllRolesHaveIdAndName
public static void validateAllRolesHaveIdAndName(Collection<AccountRoleRef> roleRefs, org.springframework.validation.Errors errors, String rolesFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode)
This validation serves purely to guarantee that each reference has an id and name.This should be called when validating a parent object that references the given roles.
- Parameters:
roleRefs
- the collection of roles to validateerrors
- the errors bound to the parent object being validatedrolesFieldNameOnParent
- the name of the field holding theseroleRefs
, which will be supplied toErrors.rejectValue(String, String, String)
if an error is encounteredmissingIdErrorCode
- the error code to set when a role is found without an id. Can be a message key.missingNameErrorCode
- the error code to set when a role is found without a name. Can be a message key.
-
validateAllRolesNonNullAndHaveId
public static void validateAllRolesNonNullAndHaveId(Collection<AccountRoleRef> roleRefs, org.springframework.validation.Errors errors, String rolesFieldNameOnParent, String nullRoleErrorCode, String missingIdErrorCode)
This validation serves purely to guarantee that each reference is not null and has an id.This should be called when validating a parent object that references the given roles.
- Parameters:
roleRefs
- the collection of roles to validateerrors
- the errors bound to the parent object being validatedrolesFieldNameOnParent
- the name of the field holding theseroleRefs
, which will be supplied toErrors.rejectValue(String, String, String)
if an error is encounterednullRoleErrorCode
- the error code to set when a null role is found. Can be a message key.missingIdErrorCode
- the error code to set when a role without an id is found. Can be a message key.
-
-