@@ -216,7 +216,7 @@ const WebsiteSsoIdentityProviderForm = ({
216216 } , [ formik , initialValues ] )
217217
218218 const handleFormSubmit = useCallback (
219- ( e : React . FormEvent < HTMLFormElement > ) => {
219+ async ( e : React . FormEvent < HTMLFormElement > ) => {
220220 e . preventDefault ( )
221221 if (
222222 ! formik . values . metaDataFile &&
@@ -226,6 +226,17 @@ const WebsiteSsoIdentityProviderForm = ({
226226 formik . setFieldTouched ( 'metaDataFile' , true )
227227 return
228228 }
229+
230+ const errors = await formik . validateForm ( )
231+ if ( Object . keys ( errors ) . length > 0 ) {
232+ const touched : Record < string , boolean > = { }
233+ Object . keys ( errors ) . forEach ( ( key ) => {
234+ touched [ key ] = true
235+ } )
236+ formik . setTouched ( touched , false )
237+ return
238+ }
239+
229240 formik . handleSubmit ( e )
230241 } ,
231242 [ formik , configs ?. idpMetaDataFN ] ,
@@ -260,9 +271,14 @@ const WebsiteSsoIdentityProviderForm = ({
260271 const error = formik . errors [ fieldName ]
261272 const touched = formik . touched [ fieldName ]
262273 const value = formik . values [ fieldName ]
263- return Boolean ( error && ( touched || ( value !== undefined && value !== null && value !== '' ) ) )
274+ return Boolean (
275+ error &&
276+ ( touched ||
277+ formik . submitCount > 0 ||
278+ ( value !== undefined && value !== null && String ( value ) . length > 0 ) ) ,
279+ )
264280 } ,
265- [ formik . errors , formik . touched , formik . values ] ,
281+ [ formik . errors , formik . touched , formik . values , formik . submitCount ] ,
266282 )
267283
268284 useEffect ( ( ) => {
@@ -394,7 +410,10 @@ const WebsiteSsoIdentityProviderForm = ({
394410 required = { ! formik . values . metaDataFileImportedFlag }
395411 lsize = { 4 }
396412 rsize = { 8 }
397- showError = { shouldShowError ( 'idpEntityId' ) }
413+ showError = { Boolean (
414+ formik . errors . idpEntityId &&
415+ ( formik . touched . idpEntityId || formik . submitCount > 0 ) ,
416+ ) }
398417 errorMessage = { formik . errors . idpEntityId }
399418 disabled = { viewOnly }
400419 doc_category = { DOC_SECTION }
@@ -411,7 +430,10 @@ const WebsiteSsoIdentityProviderForm = ({
411430 lsize = { 4 }
412431 rsize = { 8 }
413432 required = { ! formik . values . metaDataFileImportedFlag }
414- showError = { shouldShowError ( 'nameIDPolicyFormat' ) }
433+ showError = { Boolean (
434+ formik . errors . nameIDPolicyFormat &&
435+ ( formik . touched . nameIDPolicyFormat || formik . submitCount > 0 ) ,
436+ ) }
415437 errorMessage = { formik . errors . nameIDPolicyFormat }
416438 disabled = { viewOnly }
417439 doc_category = { DOC_SECTION }
@@ -427,7 +449,10 @@ const WebsiteSsoIdentityProviderForm = ({
427449 formik = { formik }
428450 lsize = { 4 }
429451 rsize = { 8 }
430- showError = { shouldShowError ( 'singleSignOnServiceUrl' ) }
452+ showError = { Boolean (
453+ formik . errors . singleSignOnServiceUrl &&
454+ ( formik . touched . singleSignOnServiceUrl || formik . submitCount > 0 ) ,
455+ ) }
431456 errorMessage = { formik . errors . singleSignOnServiceUrl }
432457 disabled = { viewOnly }
433458 doc_category = { DOC_SECTION }
@@ -441,7 +466,10 @@ const WebsiteSsoIdentityProviderForm = ({
441466 formik = { formik }
442467 lsize = { 4 }
443468 rsize = { 8 }
444- showError = { shouldShowError ( 'singleLogoutServiceUrl' ) }
469+ showError = { Boolean (
470+ formik . errors . singleLogoutServiceUrl &&
471+ ( formik . touched . singleLogoutServiceUrl || formik . submitCount > 0 ) ,
472+ ) }
445473 errorMessage = { formik . errors . singleLogoutServiceUrl }
446474 disabled = { viewOnly }
447475 doc_category = { DOC_SECTION }
@@ -456,7 +484,10 @@ const WebsiteSsoIdentityProviderForm = ({
456484 lsize = { 4 }
457485 rsize = { 8 }
458486 type = "textarea"
459- showError = { shouldShowError ( 'signingCertificate' ) }
487+ showError = { Boolean (
488+ formik . errors . signingCertificate &&
489+ ( formik . touched . signingCertificate || formik . submitCount > 0 ) ,
490+ ) }
460491 errorMessage = { formik . errors . signingCertificate }
461492 disabled = { viewOnly }
462493 rows = { 10 }
@@ -472,7 +503,10 @@ const WebsiteSsoIdentityProviderForm = ({
472503 lsize = { 4 }
473504 rsize = { 8 }
474505 type = "textarea"
475- showError = { shouldShowError ( 'encryptionPublicKey' ) }
506+ showError = { Boolean (
507+ formik . errors . encryptionPublicKey &&
508+ ( formik . touched . encryptionPublicKey || formik . submitCount > 0 ) ,
509+ ) }
476510 errorMessage = { formik . errors . encryptionPublicKey }
477511 disabled = { viewOnly }
478512 rows = { 10 }
@@ -487,7 +521,10 @@ const WebsiteSsoIdentityProviderForm = ({
487521 formik = { formik }
488522 lsize = { 4 }
489523 rsize = { 8 }
490- showError = { shouldShowError ( 'principalAttribute' ) }
524+ showError = { Boolean (
525+ formik . errors . principalAttribute &&
526+ ( formik . touched . principalAttribute || formik . submitCount > 0 ) ,
527+ ) }
491528 errorMessage = { formik . errors . principalAttribute }
492529 disabled = { viewOnly }
493530 doc_category = { DOC_SECTION }
@@ -501,7 +538,10 @@ const WebsiteSsoIdentityProviderForm = ({
501538 formik = { formik }
502539 lsize = { 4 }
503540 rsize = { 8 }
504- showError = { shouldShowError ( 'principalType' ) }
541+ showError = { Boolean (
542+ formik . errors . principalType &&
543+ ( formik . touched . principalType || formik . submitCount > 0 ) ,
544+ ) }
505545 errorMessage = { formik . errors . principalType }
506546 disabled = { viewOnly }
507547 doc_category = { DOC_SECTION }
0 commit comments