even though I think it would be OK to crush them together
ref={register({
required: true,
maxLength: 80,
positiveNumber: value => parseFloat(value) > 0,
lessThanHundred: value => parseFloat(value) < 200
})}
just to save client code keystrokes.
Also it's unclear to me how it maps values from form to model and back, espeically if the mapping isn't simple. Like, a checkbox that maps to a Date field, setting it to 60 days from now, or null, depending if the checkbox is checked.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Not bad. But not a fan of:
ref={register({
validate: {
positiveNumber: value => parseFloat(value) > 0,
lessThanHundred: value => parseFloat(value) < 200
}
})}
because it seems wordier than
ref={register({
positiveNumber: value => parseFloat(value) > 0,
lessThanHundred: value => parseFloat(value) < 200
})}
though I understand you are using keyword required in a different way, like
ref={register({
required: true,
maxLength: 80,
validate: {
positiveNumber: value => parseFloat(value) > 0,
lessThanHundred: value => parseFloat(value) < 200
}
})}
even though I think it would be OK to crush them together
ref={register({
required: true,
maxLength: 80,
positiveNumber: value => parseFloat(value) > 0,
lessThanHundred: value => parseFloat(value) < 200
})}
just to save client code keystrokes.
Also it's unclear to me how it maps values from form to model and back, espeically if the mapping isn't simple. Like, a checkbox that maps to a Date field, setting it to 60 days from now, or null, depending if the checkbox is checked.