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

(feat) Form validator built into interactive form builder #172

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

arodidev
Copy link
Contributor

@arodidev arodidev commented Aug 1, 2023

Summary

A validation tool that validates whether forms have UUIDS, checks for concepts used the in forms in the backend using the concept UUID or concept mappings provided in the form, and validates whether the datatype on the concepts align with the control type assigned in the form.

Screenshots

Screenshot 2023-08-14 at 13 47 12

Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Jammie! My general comment is: let's separate concerns here. Let's have the validation logic to exist independent of the interactive builder component in-order to keep this component simple.

src/form-validator.ts Outdated Show resolved Hide resolved
src/form-validator.ts Outdated Show resolved Hide resolved
src/form-validator.ts Outdated Show resolved Hide resolved
Comment on lines 73 to 78
const validateForm = () => {
handleFormValidation(schema).then(response => {
const [questionResolutionsArray, answersResolutionsArray] = response
setResponses(questionResolutionsArray)
})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other way of injecting the validator would be through a hook:

// the validator runs if doValidate is set to true
// isValidating shows the validation status
const { errors, warnings, isValidating } = useSchemaValidationResults(doValidate, schema);

@samuelmale
Copy link
Member

@arodidev FYI: All the checks are failing

@samuelmale
Copy link
Member

@arodidev Did you see the build failure

arodidev added 2 commits August 14, 2023 11:50
commit 3315b3a
Author: arodidev <[email protected]>
Date:   Mon Aug 14 13:32:46 2023 +0300

    Moved validation state to parent component
@@ -163,6 +168,7 @@ const FormEditor: React.FC = () => {
schema={schema}
onSchemaChange={updateSchema}
isLoading={isLoadingFormOrSchema}
validateStateSetter={validationSetter}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
validateStateSetter={validationSetter}
validateStateSetter={setIsValidating}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I would rename validateStateSetter to setIsValidating

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issues cited have been resolved, kindly review @samuelmale

@samuelmale
Copy link
Member

@denniskigen can you kindly have a look at this?

@denniskigen denniskigen changed the title (feat) Form validator built into interactive form builder. (feat) Form validator built into interactive form builder Sep 27, 2023
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

Successfully merging this pull request may close these issues.

3 participants