Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an easier way for the user to add custom errors to an existing validationResult object #77

Open
doover opened this issue Aug 2, 2023 · 0 comments

Comments

@doover
Copy link

doover commented Aug 2, 2023

Summary

Provide an easier way for the user to add custom errors to an existing validationResult object

Detailed Description

Currently, the developer can create a new validationError object two ways:

Use newError(ARGUMENTS)

Or use getInstance('cbvalidation.models.result.ValidationError') and then populate that error object

Then the developer has to use addError() to add it to the ValidationResult.

Propose a new feature - something like addNewError() (not a terribly good name) that would accept all the arguments for a validationError (like newError) and add it to the list of errors (like addError).

Possible Implementation Ideas

    /**
     * Create a new error, then add it to the current error array
     * 
     * @arguments all fields that would be part of a validationError object
     */
    any function addNewError() {
        addError(duplicate(errorTemplate).configure(argumentCollection = arguments));
        return this;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant