-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
NODE-3660 Description
Env: node 14, latest MongoDB, latest MongoDB node driver.
Validation schema:
```json
{
"validator": {
"$jsonSchema": {
"bsonType": "object",
"properties": {
"int":
,
"long":
,
"double":
,
"decimal":
}
}
},
"validationLevel": "moderate",
"validationAction": "error"
}
```
Operation:
```js
const foo= 'foo';
const data =
;
await db.collection.insertOne(data);
```
Result: inserted in db:
```js
int = 0; // as valid Int32 bsonType
long = 0; // as valid Long bsonType
double = NaN; // as valid Double bsonType
// decimal throws error:
foo not a valid Decimal128 string TypeError
```
All these 4 conversion functions are wrong, the first 3 returns the valid data type to the wrong input, and Decimal128 throws an error ... when in fact all 4 should return the wrong input so that it can then be invalidated by the validation rules.
If anything we enter is converted into a valid record... the validation is useless.
- is depended on by
-
NODE-3660 Wrong input gets validated if converted with Int32, Long or Double
- Closed