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

Adapt ValidatedTextField to accept custom validation functions #1484

Open
1 task done
Tracked by #1481
trillium opened this issue Aug 27, 2023 · 0 comments · May be fixed by #1789
Open
1 task done
Tracked by #1481

Adapt ValidatedTextField to accept custom validation functions #1484

trillium opened this issue Aug 27, 2023 · 0 comments · May be fixed by #1789

Comments

@trillium
Copy link
Member

trillium commented Aug 27, 2023

Overview

Part of #1481

The react-hook-form library has an option to pass custom validations. That's quite handy because we already have custom validations made previously from some of our existing pull requests. ValidatedTextField needs to be adapted to use these custom validations, applying the validators properly while being looped over via Array.map().

// example simpleInput
{
    ...
    name: blah
    value: blah
    validators: [  // array of validation function objects
        {
            func: mustContainBlah,
            params: undefined, // this section to be used if custom parameters
                               // need to be passed to the validaiton function
            message: "This field must contain the word 'blah'",
        },
    ],
    ... 
}     

Action Items

  • Adapt ValidatedTextField to apply custom valdations into the validate portion of the register function from react-hook-form

Resources

React Hook Form Register - search for the validate section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

3 participants