Class ValidationSupport
java.lang.Object
com.broadleafcommerce.adminuser.resource.service.validation.support.ValidationSupport
Utility class containing reusable convenience methods for validation.
- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
validateAllPermissionsHaveIdAndName
(Collection<AdminPermissionRef> permissionRefs, org.springframework.validation.Errors errors, String permissionsFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode) Deprecated.Since 1.7.0.static void
validateAllPermissionsNonNullAndHaveId
(Collection<AdminPermissionRef> 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<AdminRoleRef> roleRefs, org.springframework.validation.Errors errors, String rolesFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode) Deprecated.Since 1.7.0.static void
validateAllRolesNonNullAndHaveId
(Collection<AdminRoleRef> 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 Details
-
validateAllPermissionsHaveIdAndName
@Deprecated public static void validateAllPermissionsHaveIdAndName(Collection<AdminPermissionRef> permissionRefs, org.springframework.validation.Errors errors, String permissionsFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode) Deprecated.Since 1.7.0. Name is no longer required, thus validating that a permission has a name is no longer necessary. UsevalidateAllPermissionsNonNullAndHaveId(Collection, Errors, String, String, String)
instead.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<AdminPermissionRef> 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
@Deprecated public static void validateAllRolesHaveIdAndName(Collection<AdminRoleRef> roleRefs, org.springframework.validation.Errors errors, String rolesFieldNameOnParent, String missingIdErrorCode, String missingNameErrorCode) Deprecated.Since 1.7.0. Name is no longer required, thus validating a role has a name serves no purpose. Instead, usevalidateAllRolesNonNullAndHaveId(Collection, Errors, String, String, String)
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<AdminRoleRef> 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.
-