1 Reply Latest reply on Feb 11, 2020 10:13 AM by Duncan Mills-Oracle

    Custom component in <oj-validation-group>

    Jan Stanicek-Oracle

      I have created custom component which will be part of <oj-validation-group> and thus it is expected that it will be validated.

      I have added property "valid" which make my component tracked by oj-validation-group, but I also need to understand how the oj-validation-group component behaves and how should I teach my component to behave to conform that process.


      For example my component has optional "required" property which makes my component required depending on particular form where it is used.

      I don't want to expose property "validators" since the validator list is constant.

      I have exposed method validate which allows triggering validation process, returns promise with validation results ("valid" | "invalid"), sets valid property to "pending" | "invalid-shown" | "valid" and also apply | remove "oj-invalid" class on the component (which is supported in my css file).


      The problem is that oj-validation-group consider also "invalid-hidden" state which I don't understand how it works. oj-validation-group is able to determine whether form is invalid even when it does not trigger validations and also it visually set invalid fields as invalid.

      The only connection is method "showMessages", but what should be expected content?


      And last question is regarding the displaying validation error in "inline" shape or into "notewindow". Is it something I need to do manually, or is there some API which I may use?

        • 1. Re: Custom component in <oj-validation-group>
          Duncan Mills-Oracle

          To play nicely with oj-validation-group, you are correct you need a valid property which would be defined in the metadata like this:


             "valid": {

               "displayName": "Valid",

               "description": "The current valid state of the component.",

               "type": "string",

               "value": "valid",

               "enumValues": [






               "writeback": true,

               "readOnly": true,

               "visible": false



          You will need to maintain the value of that writeback property as the internal state of the component changes.  The invalidHidden state is for the scenario where errors had previously been shown but then, via the oj-messages component the user choose to "hide" the message.  How best to handle the management of this valid state depends on the exact setup of your component - contact me internally and we can go through the best approach