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

Extend rules with multi-word names fail #38

Closed
Jao-Quin opened this issue Jul 5, 2021 · 0 comments
Closed

Extend rules with multi-word names fail #38

Jao-Quin opened this issue Jul 5, 2021 · 0 comments

Comments

@Jao-Quin
Copy link
Contributor

Jao-Quin commented Jul 5, 2021

There's an inconsistency in the rule name parsing between extend method and parseItemRules. extend calls this.titleCase without the delimiter, so multiword rule names don't match the pattern expected by the rest of the code, e.g:

A rule called exists_in_data is saved as Exists_in_data (without delimiter) but the script expects ExistsInData (with delimiter).

I've fixed it on my end by overriding the extend method with one that calls titleCase using the delimiter:

    extend(ruleName, callback, customMessage) {
        this.customRules[this.titleCase(ruleName, '_')] = callback;

        if (customMessage) {
            this.customMessages[this.snakeCase(ruleName)] = customMessage;
        }
    }

Happy to do a pull request.

@jfstn jfstn closed this as completed in 4b0a611 Aug 1, 2021
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