grantila / grantila/suretype

Bad error message

Open
#19 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
505
Forks
8
PR merge metrics
No merged PRs in 30d

Description

I have encountered a problem in which an object with keys '1', '2', etc. and values of one type does not pass validation but the error message is wrong.

MySchema: `{
1: OtherSchema.required(),
2: OtherSchema.required(),
}`

My object: `{
1: {},
2: OtherSchemaDTO,
}`

Validation error:
` thrown: Array [
[Error: No such property '1' in . [query: '1']],
]
`

The object should not pass the validation, not for the lack of property '1', but for the invalidity of object under property '1'. The validation fails with given message even when I don't use an empty object under property '1'.

Edit:
Of course when both objects are proper (of type OtherSchemaDTO) under properties '1' and '2' the validation passes. But when I do myObject[1] = {} and then validate, it fails.

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.