-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codefeatureNew functionality or improvementNew functionality or improvement
Milestone
Description
Context
- node version: 6.2.1
- joi version: 8.4.2
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
- any other relevant information:
What are you trying to achieve or the steps to reproduce ?
I am trying to validate objects with a
Is this intentional, and if so, why is it not escaped the other places?
'use strict';
const Joi = require('joi');
const schema = {
$top: Joi.number().integer().min(1)
};
const obj = {
$top: 0
};
let result = Joi.validate(obj, schema);
console.log(result.error);Which result you had ?
$top is escaped to "$top"
{ ValidationError: child "$top" fails because ["$top" must be larger than or equal to 1]
isJoi: true,
name: 'ValidationError',
details:
[ { message: '"$top" must be larger than or equal to 1',
path: '$top',
type: 'number.min',
context: [Object] } ],
_object: { '$top': 0 },
annotate: [Function] }What did you expect ?
I expect $top to not be escaped (or escaped everywhere?)
{ ValidationError: child "$top" fails because ["$top" must be larger than or equal to 1]
isJoi: true,
name: 'ValidationError',
details:
[ { message: '"$top" must be larger than or equal to 1',
path: '$top',
type: 'number.min',
context: [Object] } ],
_object: { '$top': 0 },
annotate: [Function] }Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codefeatureNew functionality or improvementNew functionality or improvement