-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert property in array type #314
Conversation
@@ -5,6 +5,16 @@ | |||
module.exports = function ({ schema, messages }, path, context) { | |||
const src = []; | |||
|
|||
let sanitized = false; | |||
if (schema.convert === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't have to wrap the null
and undefined
values because they are no "real" values.
The current implementation will wrap the { roles: null }
to { roles: [null] }
test/rules/array.spec.js
Outdated
it("should wrap single value into array", () => { | ||
const check = v.compile({ $$root: true, type: "array", items: "string", convert: true }); | ||
expect(check("a")).toEqual(true); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more test, to check the santitized value as well, and add test when the input:
- an array with value,
- an empty array
- null
- undefined
Added null and undefined checks + deep tests as requested. The tests have been moved to the "Sanitizations" describe section as it was more meaningful based on the context |
Released |
No description provided.