Evaluating the root object with conform alters other result keys

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js
Domain
backend

Research direction

Reproduce the issue using the JavaScript example in the report and inspect how validate builds result.errors for root-level conform rules and the status field. Trace the validation result formatting, then confirm that the conform error remains separate while the notEmpty error uses the status key rather than *.status.

Written by the indexing model from the issue text.

Description

const Corro = require('corro');
const corro = new Corro();

const schema = {
  conform: [{
    func: body => !body.thing1 !== !body.thing2,
    message: 'either thing1 or thing2 must be specified'
  }],
  status: {required: true, notEmpty: true}
};

const result = corro.validate(schema, {status: ''});

'*' appears erroneously in what should be simply 'status' in the result.errors object. Omitting conform from the validation schema shows the correct 'status' key.

{
  "valid": false,
  "errors": {
    "*": [{
      "rule": "conform",
      "result": "either thing1 or thing2 must be specified"
    }],
    "*.status": [{
        "rule": "notEmpty",
        "result": "cannot be blank"
    }]
  }
}
Dominant language
JavaScript
Stars
9
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dequelabs/corro

All issues in dequelabs/corro

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.