Skip to content

Adapt ValidatedTextField to accept custom validation functions #1484

@trillium

Description

@trillium

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions