react-bootstrap icon indicating copy to clipboard operation
react-bootstrap copied to clipboard

Form.Control validation both true and false

Open ladal1 opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe

(Simple Example code at the bottom) I'm currently using a Form.Control that is validated on any input on change, and wanted to bring both valid and invalid css states to it. I have bound it to a state variable, however to have both vorking I have to bind both IsValid attribute and IsInvalid attribute, although one is just !(negation) of the other.

Describe the solution you'd like

New attribute in Form.Control, that when true applies valid state and invalid when false - maybe add null and undefined to have both still false to allow for UX options and only validating when the developer wants to

Describe alternatives you've considered

Binding both options is still a functional option, although not very developer friendly or well documented.

Example code:

<Form.Control
                isValid={this.state.field_valid}
                isInvalid={!this.state.field_valid}
                onChange={this.onChange} />

Proposed attribute (just called it validState, but there are definitely better names out there):

<Form.Control
                validState={this.state.field_valid}
                onChange={this.onChange} />

ladal1 avatar Mar 08 '21 18:03 ladal1

@ladal1 can you please review my PR and merge this?

siddharth17vaishnav avatar Oct 16 '23 15:10 siddharth17vaishnav

I'm 100% not the right person to ask that, it has been 3 years since I had this issue and I certainly don't have any ties to the project other than usage

ladal1 avatar Oct 16 '23 16:10 ladal1