AmpersandJS / ampersand-input-view

A view module for intelligently rendering and validating input. Works well with ampersand-form-view.
MIT License
17 stars 19 forks source link

Input defined as `type: 'number'` doesn't accept the value 0 #52

Closed e2jk closed 9 years ago

e2jk commented 9 years ago

In a form view created by the CLI, I have added type: 'number' (ExtendedInput is the same as from the demo app):

            new ExtendedInput({
                label: "Order",
                name: "order",
                value: this.model && this.model.order,
                type: 'number',
                required: true,
                placeholder: "Order",
                parent: this
            })

The model's property is defined as such:

        order: ['number', true, 100]

The form displays nice little up and down arrow, and using the keyboard arrows changes the values appropriately. Positive and negative values work fine, however when passing from -1 to 0, or from 1 to 0 the error message This field is required. is displayed.

It should be possible to enter a number with a value of 0.

kamilogorek commented 9 years ago

Code example: http://requirebin.com/?gist=48b40ae2a4890005cd5f (requirebin makes you change any line to rebuild dom. strange) Fix with tests: https://github.com/AmpersandJS/ampersand-input-view/pull/53

Thanks for the catch @e2jk!