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

Define invalid message object #1614

Open
samends opened this issue Dec 10, 2020 · 5 comments
Open

Define invalid message object #1614

samends opened this issue Dec 10, 2020 · 5 comments

Comments

@samends
Copy link
Contributor

samends commented Dec 10, 2020

Enhancement

Currently the interface for an invalid message object is neither defined nor exported. The invalid message object is part of the definition of Validity found at https://github.com/dojo/widgets/blob/master/src/form/middleware.ts#L4 however, more times than not, projects have to write their own interfaces for { valid: boolean, message: string }. Perhaps we could define and export a new interface for this with the name InvalidMessage

Package Version: 7.0.3

@samends samends self-assigned this Jan 15, 2021
@tomdye
Copy link
Member

tomdye commented Mar 22, 2021

I don't think we should be exporting this interface. Perhaps we should instead change to always export the same object with a valid boolean and optional message. This needs investigating further.

@samends
Copy link
Contributor Author

samends commented Mar 23, 2021

@tomdye you mean change the invalid type on the widgets to only be { valid: boolean, message: string } and not { valid: boolean, message: string } | true that would certainly lessen alot of logic that has to go in to handle two different types

@tomdye
Copy link
Member

tomdye commented Mar 23, 2021

Correct, I'm not sure why it was done that way in the first place. I'm just thinking out loud here though - would this approach work for all our validated widgets?

@samends
Copy link
Contributor Author

samends commented Mar 26, 2021

I think so, I'm also not sure why it's currently { valid: boolean, message: string } | true, it seems to really complicate the logic for not alot of gain

@samends
Copy link
Contributor Author

samends commented Mar 26, 2021

I took at quick look at where this is used in the code base and it seems like 4 places would need to get updated:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants