@@ -186,17 +186,32 @@ const ManageGroupForm = ({ data, onSubmit, readOnly }: ManageGroupFormProps) =>
186186 initialValues = { initialValues }
187187 preventResetValuesOnReset = { true }
188188 readOnly = { readOnly }
189- validationSchema = { z . object ( {
190- accessibleFormInstrumentIds : z . set ( z . string ( ) ) ,
191- accessibleInteractiveInstrumentIds : z . set ( z . string ( ) ) ,
192- defaultIdentificationMethod : $SubjectIdentificationMethod . optional ( ) ,
193- idValidationRegex : $RegexString . optional ( ) ,
194- idValidationRegexErrorMessageEn : z . string ( ) . optional ( ) ,
195- idValidationRegexErrorMessageFr : z . string ( ) . optional ( ) ,
196- minimumAge : z . number ( ) . int ( ) . positive ( ) . optional ( ) ,
197- minimumAgeApplied : z . boolean ( ) . optional ( ) ,
198- subjectIdDisplayLength : z . number ( ) . int ( ) . min ( 1 ) . optional ( )
199- } ) }
189+ validationSchema = { z
190+ . object ( {
191+ accessibleFormInstrumentIds : z . set ( z . string ( ) ) ,
192+ accessibleInteractiveInstrumentIds : z . set ( z . string ( ) ) ,
193+ defaultIdentificationMethod : $SubjectIdentificationMethod . optional ( ) ,
194+ idValidationRegex : $RegexString . optional ( ) ,
195+ idValidationRegexErrorMessageEn : z . string ( ) . optional ( ) ,
196+ idValidationRegexErrorMessageFr : z . string ( ) . optional ( ) ,
197+ minimumAge : z . number ( ) . int ( ) . positive ( ) . optional ( ) ,
198+ minimumAgeApplied : z . boolean ( ) . optional ( ) ,
199+ subjectIdDisplayLength : z . number ( ) . int ( ) . min ( 1 ) . optional ( )
200+ } )
201+ . check ( ( ctx ) => {
202+ if ( ctx . value . minimumAgeApplied && ! ctx . value . minimumAge ) {
203+ ctx . issues . push ( {
204+ code : 'custom' ,
205+ input : ctx . value . minimumAge ,
206+ message : t ( {
207+ en : 'Please enter an age' ,
208+ fr : "Entrez un âge s'il vous plait"
209+ } ) ,
210+ path : [ 'minimumAge' ]
211+ } ) ;
212+ }
213+ return ;
214+ } ) }
200215 onSubmit = { ( data ) => {
201216 void onSubmit ( {
202217 accessibleInstrumentIds : [ ...data . accessibleFormInstrumentIds , ...data . accessibleInteractiveInstrumentIds ] ,
@@ -207,8 +222,7 @@ const ManageGroupForm = ({ data, onSubmit, readOnly }: ManageGroupFormProps) =>
207222 en : data . idValidationRegexErrorMessageEn ,
208223 fr : data . idValidationRegexErrorMessageFr
209224 } ,
210- minimumAge : data . minimumAge ,
211- minimumAgeApplied : data . minimumAgeApplied ,
225+ minimumAge : data . minimumAgeApplied ? data . minimumAge : null ,
212226 subjectIdDisplayLength : data . subjectIdDisplayLength
213227 }
214228 } ) ;
@@ -249,7 +263,7 @@ const RouteComponent = () => {
249263 idValidationRegexErrorMessageEn : settings ?. idValidationRegexErrorMessage ?. en ,
250264 idValidationRegexErrorMessageFr : settings ?. idValidationRegexErrorMessage ?. fr ,
251265 minimumAge : settings ?. minimumAge ,
252- minimumAgeApplied : settings ?. minimumAgeApplied ,
266+ minimumAgeApplied : typeof settings ?. minimumAge === 'number' ,
253267 subjectIdDisplayLength : settings ?. subjectIdDisplayLength
254268 } ;
255269 for ( const instrument of availableInstruments ) {
0 commit comments