ConvertFieldAPIRulesToJoi.ts
7 months ago
PrepareFormData.ts
2 years ago
amountFormatter.ts
2 years ago
buildRegisterValidationOptions.ts
2 years ago
conditionOperatorFunctions.js
2 years ago
convertValuesToFormData.ts
2 years ago
createValidationObjectFromFields.js
2 years ago
generateRequestErrors.ts
1 year ago
getCurrentFormUrlData.js
1 year ago
getDefaultValuesFromSections.ts
2 years ago
getDonationFormNodeSettings.ts
2 years ago
getErrorByFieldName.ts
2 years ago
getWindowData.ts
2 years ago
groups.ts
2 years ago
handleFormRedirect.ts
1 year ago
handleFormSubmitRequest.ts
1 year ago
handleValidationRequest.ts
2 years ago
isRouteInlineRedirect.ts
2 years ago
memoNode.ts
2 years ago
mountWindowData.ts
1 year ago
postData.ts
2 years ago
postFormData.ts
2 years ago
registerFieldAndBuildProps.tsx
1 year ago
setDesignSettings.ts
2 years ago
useDonationFormPubSub.ts
1 year ago
buildRegisterValidationOptions.ts
17 lines
| 1 | /** |
| 2 | * Builds the expected registration options from the Field API validation rules |
| 3 | * |
| 4 | * @since 3.0.0 |
| 5 | */ |
| 6 | import {RegisterOptions} from 'react-hook-form'; |
| 7 | |
| 8 | export default function buildRegisterValidationOptions(validationRules: {[key: string]: any}): RegisterOptions { |
| 9 | return ['required', 'maxLength', 'minLength'].reduce((rules, rule) => { |
| 10 | if (validationRules.hasOwnProperty(rule)) { |
| 11 | rules[rule] = validationRules[rule]; |
| 12 | } |
| 13 | |
| 14 | return rules; |
| 15 | }, {}); |
| 16 | } |
| 17 |