dequelabs / dequelabs/corro

Evaluating the root object with conform alters other result keys

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9
Forks
2
PR merge metrics
No merged PRs in 30d

Description

```js
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.

```json
{
"valid": false,
"errors": {
"*": [{
"rule": "conform",
"result": "either thing1 or thing2 must be specified"
}],
"*.status": [{
"rule": "notEmpty",
"result": "cannot be blank"
}]
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.