java.lang.Object
com.broadleafcommerce.adminuser.resource.service.validation.support.ValidationSupport

public final class ValidationSupport extends Object
Utility class containing reusable convenience methods for validation.
Author:
Samarth Dhruva (samarthd)
  • 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. Use validateAllPermissionsNonNullAndHaveId(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 validate
      errors - the errors bound to the parent object being validated
      permissionsFieldNameOnParent - the name of the field holding these permissionRefs, which will be supplied to Errors.rejectValue(String, String, String) if an error is encountered
      missingIdErrorCode - 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 validate
      errors - the errors bound to the parent object being validated
      permissionsFieldNameOnParent - the name of the field holding these permissionRefs, which will be supplied to Errors.rejectValue(String, String, String) if an error is encountered
      nullPermissionErrorCode - 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, use validateAllRolesNonNullAndHaveId(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 validate
      errors - the errors bound to the parent object being validated
      rolesFieldNameOnParent - the name of the field holding these roleRefs, which will be supplied to Errors.rejectValue(String, String, String) if an error is encountered
      missingIdErrorCode - 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 validate
      errors - the errors bound to the parent object being validated
      rolesFieldNameOnParent - the name of the field holding these roleRefs, which will be supplied to Errors.rejectValue(String, String, String) if an error is encountered
      nullRoleErrorCode - 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.