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

Form.Control validation both true and false #5709

Open
ladal1 opened this issue Mar 8, 2021 · 2 comments
Open

Form.Control validation both true and false #5709

ladal1 opened this issue Mar 8, 2021 · 2 comments

Comments

@ladal1
Copy link

ladal1 commented Mar 8, 2021

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} />
@siddharth17vaishnav
Copy link

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

@ladal1
Copy link
Author

ladal1 commented Oct 16, 2023

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

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

2 participants