Class ValidationSupport


  • public final class ValidationSupport
    extends Object
    Utility class containing reusable convenience methods for validation.
    Author:
    Samarth Dhruva (samarthd), Chris Kittrell (ckittrell)
    • 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 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<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 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

        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 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<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 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.