Skip to content
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

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

Open
zerkms opened this issue Sep 18, 2024 · 2 comments · May be fixed by #495
Open

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

zerkms opened this issue Sep 18, 2024 · 2 comments · May be fixed by #495
Assignees
Labels
Type: Enhancement Most issues will probably ask for additions or changes.

Comments

@zerkms
Copy link
Contributor

zerkms commented Sep 18, 2024

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.

@zerkms zerkms added the Type: Enhancement Most issues will probably ask for additions or changes. label Sep 18, 2024
@azjezz azjezz assigned veewee and unassigned azjezz Sep 19, 2024
@veewee
Copy link
Collaborator

veewee commented Sep 19, 2024

Hi @zerkms,

That sure is possible. Care to give it a PR?
Related exception lines in code:

@zerkms
Copy link
Contributor Author

zerkms commented Sep 19, 2024

Related exception lines in code:

Yep, I already debugged through it :-) It was also to confirm whether the corresponding change would be accepted/welcomed overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants