@maryojo/react-flexform
v1.0.0
Published
Auto generate React form using JSON schema
Downloads
2
Readme
@maryojo/react-flexform
Auto generate React form using JSON schema
Install
npm install --save @maryojo/react-flexform
Usage
import React from 'react'
import { FormGenerator } from '@maryojo/react-flexform'
import 'react-flexform/dist/index.css'
import formSchema from './schema/form.json'
const customValidations = {
customPhoneValidation: (val) => {
if (val?.length < 11) {
return 'Invalid email address'
}
return null
},
customEmailValidation: (val) => {
if (!val?.includes('@')) {
return 'Invalid email address'
}
return null
}
}
const App = () => {
return (
<>
<div style={{ width: '50%' }}>
<FormGenerator
schema={formSchema}
customValidations={customValidations}
/>
</div>
</>
)
}
export default App
License
MIT © maryojo