kbss-cvut / s-forms

SForms - Semantic form generator and processor. For ontology-based smart forms.
GNU Lesser General Public License v3.0
4 stars 7 forks source link

Add validation visitor to all questions #286

Closed LaChope closed 7 months ago

LaChope commented 7 months ago

Options to implement validation in Record Manager UI:

1) implement a specific method like SForms.validate() 2) implement as properties of SForms

1)

this.refForm = React.createRef();
this.refForm.current.validate(evaluateCompleteness = false);

BTW, RecordForm has state isValid.

It is possible to think about implementation of generic visitor of all questions (would be used for both, getting list of invalid/incomplete questions and changing "in/valid" state of questions)

process_question: (question) => object

Example of processors:

showRequiredToSave(question) {
    question.validate();
}
collectRequiredToSave(question) {
    if not_valid(question) { 
      listOfFailedQuestions.add(question)
   }
}

2) It would be something like <SForms showAllInvalid=true/> and <SForms showAllIncomplete=true/>.

Originally posted by @blcham in https://github.com/kbss-cvut/record-manager-ui/issues/101#issuecomment-1993862218