Skip to content

New v3 path error message should distinguish between "lack of key" and "key equals null" #494

Open
@zerkms

Description

@zerkms

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Type\shape(['foo' => Type\string()], true)->assert([]);
Type\shape(['foo' => Type\string()], true)->assert(['foo' => null]);

Both these two evaluations result in a AssertException with a Expected "array{'foo': string}", got "null" at path "foo". message.

It's misleading as the lack of the key is definitely different beast to the key that is = null.

Describe the solution you'd like
I would prefer two distinct messages (non-native speaker here, so needs polishing):

Expected "array{'foo': string}", path "foo" does not exist.
Expected "array{'foo': string}", got "null" at path "foo".

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

Labels

Type: EnhancementMost issues will probably ask for additions or changes.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions