js-validator-livr icon indicating copy to clipboard operation
js-validator-livr copied to clipboard

Fixes for 'list_of_different_objects' rule error handling

Open pustovitDmytro opened this issue 1 year ago • 0 comments

This pull request addresses two issues related to the 'list_of_different_objects' rule. Consider the following rule:

{
    "comments": [ { "list_of_different_objects": [
        "type", {
            "web": {
                "type": "required",
                "url": [ "required", "string" ]
            },
            "plain": {
                "type": "required",
                "text": ["required", "string" ]
            }
        }
    ]}]
}

The following fixes have been implemented:

  1. Bug Fix: hasErrors flag not triggered on "FORMAT_ERROR" errors
     **Problem**: The `hasErrors` flag was not correctly indicating errors when the input format was invalid.
     **Example**:
         Input: [ "not object" ]
         Result (Before Fix): valid empty array ([])
         Result (After Fix): ["FORMAT_ERROR"]
    
  2. Enhancement: More Descriptive Errors for wrong selectors
     **Problem**: When encountering wrong selectors, the error messages were not sufficiently descriptive.
     **Example**:
         Input: [{"type": "wrong type"}, {"url": "https://ag-lotinegaingcor.kyoto"} ]
         Result (Before Enhancement): ["FORMAT_ERROR", "FORMAT_ERROR"]
         Result (After Enhancement): [{type: "NOT_ALLOWED_VALUE"}, {type: "REQUIRED"}]
    

The fixes and enhancements included in this pull request have been thoroughly tested to ensure their correctness and effectiveness.

pustovitDmytro avatar Jul 18 '23 12:07 pustovitDmytro