Validation with external parameters
How to implement validation with external parameters (w/o rules hardcoding, like lt8)? (e.g. minLength, maxLength)
Hey @SergeyNedayvoda ,
What's the purpose of that? Could you just define that rule like lt8?
Thanks, Oleksii
Hi @Lesha-spr , Thanks for the answer
I will describe the situation
We have a lot fields with different length rules (e.g. 1st field: 10-20 symbols, 2nd: 15-25, 3rd: 15-35, n:X-Y symbols)
We don't want to define separate rules for each case. Ideally we should be able to pass parameters from component to the validator (maybe like validations={['alpha', 'minLength:10', 'maxLength:20']})
Or maybe we should pass component to the rule/hint function (currently we pass only (value, components)), so we'll be able to get the dynamic parameters for validation from the component attributes
e.g. <Validation.components.Input type='text' value='' minLength='10' maxLength='20' validations={['alpha', 'minLength', 'maxLength']}/>
+this functionality will be useful if we want to define a different error messages for an one rule I can provide a lot of scenarios when access to the component attributes or dynamic parameters would be useful
Thanks
Hi @Lesha-spr ,
are there any news about this issue?
Thanks
@SergeyNedayvoda Did you find a solution, or can you recommend a library which handles the dynamic nature of forms and fields?
@melchoir55 we use formsy-react and formsy-material-ui components