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

NaN bypass number schema and minValue validation #157

Closed
dinwwwh opened this issue Sep 13, 2023 · 3 comments
Closed

NaN bypass number schema and minValue validation #157

dinwwwh opened this issue Sep 13, 2023 · 3 comments
Assignees
Labels
bug Something isn't working priority This has priority

Comments

@dinwwwh
Copy link

dinwwwh commented Sep 13, 2023

version: 0.15.0

var v = require("valibot")

console.log(
v.parse(v.coerce(v.number([v.minValue(1)]), Number), undefined)
)

actual result: NaN
expected result: throw error

@dinwwwh dinwwwh changed the title NaN bypass number schema when combine with coerce method NaN bypass number schema and minValue validation Sep 13, 2023
@fabian-hiller
Copy link
Owner

Thank you for creating this issue. The problem is that both checks return false. I will investigate this in the coming days. As a workaround you could add another check, for example integer validation.

const value = Number(undefined);
const boolean1 = value < 1; // false
const boolean2 = value > 1; // false

@fabian-hiller fabian-hiller self-assigned this Sep 13, 2023
@fabian-hiller fabian-hiller added bug Something isn't working priority This has priority labels Sep 13, 2023
@fabian-hiller
Copy link
Owner

The problem will be fixed in the next version

@fabian-hiller
Copy link
Owner

The new version is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority This has priority
Projects
None yet
Development

No branches or pull requests

2 participants