Open yunlong-tang opened 6 years ago
In my project, I have many forms need to be validated. Instead of putting these functions in every Form component, is there any way we can share these functions? All these functions are duplicated in the different components.
constructor(props) { super(props); this.validatorTypes = { username: Joi.string().alphanum().min(3).max(30).required().label('Username'), password: Joi.string().regex(/[a-zA-Z0-9]{3,30}/).label('Password') }; this.getValidatorData = this.getValidatorData.bind(this); this.renderHelpText = this.renderHelpText.bind(this); this.getClasses = this.getClasses.bind(this); this.onChange = this.onChange.bind(this); this.onSubmit = this.onSubmit.bind(this); }
In my project, I have many forms need to be validated. Instead of putting these functions in every Form component, is there any way we can share these functions? All these functions are duplicated in the different components.