Closed kgdev closed 8 years ago
Could pull a "required" error message from errorMessages
here:
https://github.com/cerebral/cerebral-module-forms/blob/misc-features/actions/validateRequired.js#L11
and here
https://github.com/cerebral/cerebral-module-forms/blob/misc-features/helpers/configureField.js#L26
@kgdev You could just use minLength:1
required != minLength:1
If the field is optional and it's empty, it will by pass all the other rules.
Yeah, I agree with @abalmos on adding a field for the required error message. Required and validation are two different things really. As required means "no value" and validations means "Value, but invalid value".
So a requiredMessage
f.ex.
Sound good!
@christianalfoni @Guria Then maybe we can close this issue?
Form({
name: {
isRequired: true,
value: ''
requiredMessage: 'Please Fill in the data'
}
})
Later in Component
renderRequiredMessage(){
const {form} = this.props;
// render requiredMessage based on conditions
}
Yeah, this sounds like a good thing, you want to implement @edgesoft ? :)
@christianalfoni Do we really need to implement this? When constructing the form just pass requiredMessage as an option, and in the view layer check isTouched?
Ah, yeah, sorry... good point :)
@kgdev I'm closing this. Reopen it again if this approach doesn't work for you.
Right now there is no way to provide an error message for a required field if it has no valid.