-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add validation and visibility on errors #22
Comments
I've made some progress but I would like a doublecheck before I keep moving forward @francisconeves97 |
Hey @mikemajara! This is an amazing contribution and idea. 🚀 Currently I don't have much time to help you on this, but I will try to when I have got the time. Maybe an idea to get this thing started is to start by only adding one type of validation. Maybe a simple one like length validation on the short text input. This way it would be much easier for me to review your work 🙏 after you have that one I can review the PR and maybe give some ideas After the first validation is in place we can start implementing the others using the same strategy. What do you think of this? |
Looking at your fork I see that you already did an amazing job and lots of work, thank you for that. I would only give a suggestion, and let me know what you think: I see that you are storing the validation function on the parsed json. I think this has some problems:
In my opinion I think the json object should only contain metadata about the google form, and not code. I would maybe add a new type: interface Validation {
type: ValidationType
}
type LengthRule = 'MAX' | 'MIN'
interface LengthValidation extends Validation {
type: 'LENGTH'
rule: LengthRule
length: number
}
interface TextField extends BaseField {
type: 'SHORT_ANSWER' | 'LONG_ANSWER'
options: any
validation: LengthValidation
} This is from the top of my head, so please feel free to change or discuss new ideas 🙏 But I think this would follow the pattern that was used for the different field types as well. |
Yeah that is a nice point, maybe this would be the way to implement this with less friction considering how the code is structured right now.
I agree with this suggestion, and after all it should be what google is doing. They have this metadata of the form, and they dynamically build the validations on the client. Regarding alternative suggestions, I am not as familiar as you with the validation code but building on top of the types I mentioned before I developed this poc branch: https://github.com/francisconeves97/react-google-forms-hooks/compare/validation-poc Let me know what you think of this approach. Don't mind the types and some parts of the code, just a rough sketch of what we could do. I think it wouldn't be that much intrusive, since we would be creating a new reusable layer to build the validation functions. Let me know what you think 🚀 |
The library as is doesn't show some (if not all) errors.
Given Google manages that within the browser we need to parse that out of the
form-raw.json
and add it to the validation object available in react-hook-form to validate previous to submit.I've been exploring how this can be done (check in my fork's master)
This would be the list for Short Answers, which would be the first thing I'd focus on
The text was updated successfully, but these errors were encountered: