-
Notifications
You must be signed in to change notification settings - Fork 7
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
Basic validation #207
Basic validation #207
Conversation
✅ Deploy Preview for s-forms-kbss ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@blcham test There are two cases of validation to consider. And then there is the option of combining these two. |
With the ValidatorFactories, there might be a problem when chaining different data rules and requirements. Imagine these situations:
Plus there are code duplicities in ValidatorFactory, I might propose cleaner solution later. Abstract proposal for chaining multiple rules:
Checking data types is done by correct data type definition in JSONLD when generating form, and then For example: Scan flag 'required' and 'pattern' from JSONLD data structure. Then |
69dff40
to
8ccb2e4
Compare
@VojtechLunak I rebased your implementation of validators but it fails in tests |
Less important:
|
248f8c0
to
e6ede20
Compare
We need only following properties:
We need only following properties:
@LaChope we agreed on 2. Proposal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/stories/assets/form/touristDestinationForm2WithValidation.json
Outdated
Show resolved
Hide resolved
@blcham These are the messages from the pattern validator. I am not sure how to make better messages, it used to be the regex displayed but IMO it does not make sense to show it to the end user. This message is the same one used in Google Forms but I agree that it could be more explicit, do you have any recommendations? My argument is that if we say something like "The pattern is not matched" or something similar, the user will expect to have the pattern, but regex will not be understandable. "Enter a valid answer" to me is not specific on purpose and relies on the user to understand the question. |
Validation message should support custom message, if no custom message, show regex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider my comments. Moreover, I have a suggestion to meet over !important
.
I was able to fix it by simply adding the properties to |
src/stories/assets/form/touristDestinationForm2WithValidation.json
Outdated
Show resolved
Hide resolved
props.validation = "error"; | ||
if ( | ||
question[Constants.USED_ONLY_FOR_COMPLETENESS] === true && | ||
question[Constants.HAS_VALIDATION_TYPE] === |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe should not be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually yes, sorry I was confused
a78273c
to
5b6d07a
Compare
Implements also #153.
InputAnswer
PATTERN
attribute introduced to JSONLD question object ~ Regex expressionHAS_VALIDATION_MESSAGE
contains the message that shows when there is invalid inputDefaultInput
isInvalid
state and show error messageFurther analysis
@blcham
ValidatorFactory
Question
component in_handleChange
methodConstants.REQUIRES_ANSWER
Constants.HAS_VALID_ANSWER
totrue
, else it sets it tofalse
and setsConstants.HAS_VALIDATION_MESSAGE
as wellConstants.HAS_VALID_ANSWER
totrue
by defaultDefaultInput
onSubmit
(when the submit button of the form is clicked)