@croz/nrich-form-configuration-core
Advanced tools
Comparing version 2.0.0 to 2.1.0
import * as yup from 'yup'; | ||
import { ObjectSchema } from 'yup'; | ||
import * as yup_lib_object from 'yup/lib/object'; | ||
@@ -15,3 +16,3 @@ import React from 'react'; | ||
} | ||
interface FormYupConfiguration { | ||
interface FormYupConfiguration<T extends Record<string, never> = any> { | ||
/** | ||
@@ -24,3 +25,3 @@ * Registered form id for this form configuration. | ||
*/ | ||
yupSchema: yup.ObjectSchema<any>; | ||
yupSchema: yup.ObjectSchema<T>; | ||
} | ||
@@ -134,3 +135,3 @@ interface ConstrainedPropertyConfiguration { | ||
*/ | ||
declare const useYupFormConfiguration: (formId: string) => yup.ObjectSchema<any, yup_lib_object.AnyObject, yup_lib_object.TypeOfShape<any>, yup_lib_object.AssertsShape<any>>; | ||
declare const useYupFormConfiguration: <T extends Record<string, any> = any>(formId: string) => ObjectSchema<T, yup_lib_object.AnyObject, yup_lib_object.TypeOfShape<T>, yup_lib_object.AssertsShape<T> | Extract<yup_lib_object.TypeOfShape<T>, null>>; | ||
@@ -137,0 +138,0 @@ type Props = { |
{ | ||
"name": "@croz/nrich-form-configuration-core", | ||
"description": "Contains core utilities related to the nrich-form-configuration module", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"author": "CROZ", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/croz-ltd/nrich-frontend/issues", |
@@ -36,6 +36,9 @@ # @croz/nrich-form-configuration-core | ||
type CreateForm = { | ||
/* fields of the form */ | ||
} | ||
export const SomeFormComponent = () => { | ||
const [formValues, setFormValues] = useState({}); | ||
const validationSchema = useYupFormConfiguration('user.create-form'); | ||
const validationSchema = useYupFormConfiguration<CreateForm>('user.create-form'); | ||
@@ -48,3 +51,3 @@ return ( | ||
<Form> | ||
{ /* Rest of the form */ } | ||
{ /* Rest of the form */} | ||
</Form> | ||
@@ -55,2 +58,3 @@ </Formik> | ||
``` | ||
*NOTE: Formik is used just as an example, you can use any form lib compatible with `yup`.* | ||
@@ -70,3 +74,2 @@ | ||
### Registering and using custom validations | ||
@@ -73,0 +76,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74835
595
103