svelte-forms icon indicating copy to clipboard operation
svelte-forms copied to clipboard

[BUG]: min() function doesn't work with a string of numbers only

Open giosifelis opened this issue 1 year ago • 1 comments

Describe the bug

The function min(5) doesn't work if the value is a string of numbers ONLY ie: '123'.

To Reproduce Steps to reproduce the behavior:

  1. use min(5) with input '123'
  2. the output will be valid:true

Expected behavior the output on the above example should be valid: false

Solution

change: const val = isNaN(value) ? value.length : parseFloat(value); to: const val = typeof value === 'string' ? value.length : isNaN(value) ? 0 : parseFloat(value)

giosifelis avatar Jun 09 '24 15:06 giosifelis

I just saw multiple issues for this. https://github.com/chainlist/svelte-forms/issues/103, https://github.com/chainlist/svelte-forms/issues/88

I have a proposed solution in the description above

giosifelis avatar Jun 09 '24 15:06 giosifelis