Validation API Not Working - "Model does not contain validation widgets"
Question
Application Type
Reactive

I'm trying to get validation rules set up on our project to work from just giving validation classes to inputs. I found the built-in validation API ($public.Validation.setWidgetAsInvalid) and already have found that it doesn't work if you use it in a client action on the Logic tab. It has to be in a screen client action.

I got it to work in a test where the validation block contains all of the inputs being validated, but when I try to make a generic solution that validates all fields on the page instead of fields inside of the block, it breaks.

I'm attaching the oap file with the two modules I'm using for these tests. The 'ValidationTests' module shows a working example as well as the example that throws the error in my title.

Validation.rar

Hi Eric,

I have been struggling with this in the past.

There are 2 things to solve :

Each block screen has his own $public.validation... context with access to execute the api only on its own fields, so you´ ll have to pass them into your generic solution.

You´ll have to find a way to trigger a rerender on each screen / block from within your generic solution .

I´ ll try to make a demo app tonight.

Dorine

Hi Eric,

see attached demo oml

So here's what is going on :

  • All validation code is in a script
  • The script is attached as required script to the screen
  • the screen and all blocks that have to-be-validated inputs need an onReady where they register their $public with the validation script
  • the screen has a dummy variable put on the screen as a display-none input(this is what I have found to work for triggering a re-render of all inputs, don't know why and don't know if there are nicer ways)
  • Validate can only be triggered from the screen by calling function from the script and upping the dummy variable
  • Validate from block could be done by bubbling up event to the screen (as shown in demo on BlockX)

Dorine

Caveat 1 : I'd like to add that all of this might have a lot of overlap with existing built-in validations, and I'm not sure I fully understand why it is not just done with straight-forward low code validation logic in a screen action, but if those are not covering your needs, above might be a direction to explore.

Caveat 2 : None of the above is thouroughly tested, just a demo of the direction you could take


QDR_Validation.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.