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

isNotEmpty on a numeric field #1143

Closed
Tommuh opened this issue Apr 9, 2024 · 2 comments
Closed

isNotEmpty on a numeric field #1143

Tommuh opened this issue Apr 9, 2024 · 2 comments

Comments

@Tommuh
Copy link

Tommuh commented Apr 9, 2024

I have a numeric field with the "isNotEmpty" rule on it.

This numeric field is required. The value "0" is allowed in my use case (0 kg for example).
Leaving the field empty is not allowed.

My problem is that "isNotEmpty" handles 0 as empty (as stated in the documentation) and triggers the error.

I do not know how to solve this problem, can someone please help me with this?

@ealush
Copy link
Owner

ealush commented Apr 9, 2024

I think that in your case isNotBlank would work better:

https://vestjs.dev/docs/enforce/enforce_rules#isnotblank

enforce(0).isNotBlank(); // passes

@Tommuh
Copy link
Author

Tommuh commented Apr 12, 2024

Thank you - that did the trick.

@Tommuh Tommuh closed this as completed Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants