js-validator-livr
js-validator-livr copied to clipboard
Fixes for 'list_of_different_objects' rule error handling
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:
-
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"]
-
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.