From 52f8d93d54268716d4afcaee73313e34bc44f7fc Mon Sep 17 00:00:00 2001 From: Amit Badala Date: Sat, 11 Nov 2023 11:45:02 +0530 Subject: [PATCH] feat: add nonOptionalErrorMsg props (#757) * Add nonOptionalErr types * Now supports nonOptionalErrorMsg attribute * Add tests and fix signin types to include nonOptionalMsg * Enforce no api request are made on blank forms * Clean up signup * Throw error if invalid nonOptionalErrorMsg, add tests for the same * Better error message * Handle incorrect optional flag * fixes redundant normalisation --------- Co-authored-by: rishabhpoddar --- examples/for-tests/src/App.js | 22 ++++ lib/build/emailpassword-shared4.js | 7 + lib/build/emailpassword-shared7.js | 47 +++++-- .../submitNewPassword.d.ts | 2 +- .../components/themes/signInAndUp/signIn.d.ts | 4 +- .../components/themes/signInAndUp/signUp.d.ts | 7 +- .../components/themes/translations.d.ts | 6 - .../components/themes/translations.d.ts | 5 - lib/build/types.d.ts | 2 + .../components/library/formBase.tsx | 16 ++- lib/ts/recipe/emailpassword/utils.ts | 7 + lib/ts/types.ts | 10 ++ test/end-to-end/signin.test.js | 44 +++++++ test/end-to-end/signup.test.js | 124 +++++++++++++++++- test/with-typescript/src/App.tsx | 2 + 15 files changed, 272 insertions(+), 33 deletions(-) diff --git a/examples/for-tests/src/App.js b/examples/for-tests/src/App.js index 505beeb61..7c546a35d 100644 --- a/examples/for-tests/src/App.js +++ b/examples/for-tests/src/App.js @@ -279,12 +279,19 @@ const incorrectFormFields = [ return "Please check Terms and conditions"; }, }, + { + id: "city", + label: "Your city", + optional: false, + nonOptionalErrorMsg: "", // empty string should throw error + }, ]; const customFields = [ { id: "select-dropdown", label: "Select Dropdown", + nonOptionalErrorMsg: "Select dropdown is not an optional", inputComponent: ({ value, name, onChange }) => (