d98c_dynamic-forms
v2.0.1
Published
React Dynamic Form with Formik and Yup validations
Downloads
2
Readme
d98c_dynamic-forms
React Dynamic Form with Formik and Yup validations
Install
npm install --save d98c_dynamic-forms
Usage
import React, { Component } from 'react'
import DynamicForm from 'd98c_dynamic-forms'
class Example extends Component {
render() {
return (
<DynamicForm
formInputs={formInputs}
onSubmit={(values) => console.log(values)}
/>
)
}
}
Input Required Object
You should provide an object array with the data for the input fields, following the next schema.
const formInputs = [
{
name: string,
value: string | number | boolean,
placeholder?: string,
label?: string,
inline?: 'true' | 'false',
type: 'text' | 'radio-group' | 'email' | 'password' | 'select' | 'checkbox' | 'header',
typeValue?: 'string' /* default */ | 'boolean' | 'number' | '',
options?: [
{
value: string | number
desc: string
}
],
//See validations section
validations: [
{
type: 'required'
value?: string
message: string
}
]
}
]
Validations
List of supported validators by typeValue. In case that the typeValue attribute is not set, it'll be managed as a string.
If a wrong rule type is set, the whole rule would be ignored.
License
MIT © danny1998cuba