@@ -95,7 +95,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
9595
9696 const labelEl = < label className = { ( required ) ? styles . fieldRequired + ' ' + styles . fieldLabel : styles . fieldLabel } > { labelText } </ label > ;
9797 const errorText = this . getRequiredErrorText ( ) ;
98- const errorTextforNumber = this . getnumberErrorText ( ) ;
98+ const errorTextforNumber = this . getNumberErrorText ( ) ;
9999 const errorTextEl = < text className = { styles . errormessage } > { errorText } </ text > ;
100100 const descriptionEl = < text className = { styles . fieldDescription } > { description } </ text > ;
101101 const hasImage = ! ! changedValue ;
@@ -139,7 +139,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
139139 value = { value }
140140 className = { styles . fieldDisplay }
141141 onChange = { ( newText ) => { this . onChange ( newText ) ; return newText ; } }
142- isEditMode = { ! disabled } />
142+ isEditMode = { ! disabled } />
143143 { descriptionEl }
144144 { errorTextEl }
145145 </ div > ;
@@ -588,28 +588,30 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
588588 const {
589589 changedValue
590590 } = this . state ;
591- return ( changedValue === undefined || changedValue === '' || changedValue === null || this . isEmptyArray ( changedValue ) ) && this . props . required ? strings . DynamicFormRequiredErrorMessage : null ;
591+ return ( changedValue === undefined || changedValue === '' || changedValue === null || this . isEmptyArray ( changedValue ) ) && this . props . required ? strings . DynamicFormRequiredErrorMessage : null ;
592592 }
593593
594- private getnumberErrorText = ( ) : string => {
594+ private getNumberErrorText = ( ) : string => {
595595 const {
596596 changedValue
597597 } = this . state ;
598- const {
598+ const {
599599 maximumValue,
600600 minimumValue,
601601 showAsPercentage
602602 } = this . props ;
603603
604- if ( ( changedValue === undefined || changedValue === '' || changedValue === null || this . isEmptyArray ( changedValue ) ) && this . props . required ) {
605- return strings . DynamicFormRequiredErrorMessage ;
606- } else if ( ( changedValue < minimumValue ) || ( changedValue > maximumValue ) ) {
607- if ( ! showAsPercentage ) {
608- return strings . DynamicFormNumberErrorMessage
609- . replace ( '{0}' , minimumValue . toString ( ) )
610- . replace ( '{1}' , maximumValue . toString ( ) ) ;
604+ let errorText : string | null = null ;
605+
606+ errorText = this . getRequiredErrorText ( ) ;
607+ if ( ! errorText && ( changedValue < minimumValue ) || ( changedValue > maximumValue ) ) {
608+ if ( ! showAsPercentage ) {
609+ errorText = strings . DynamicFormNumberErrorMessage
610+ . replace ( '{0}' , minimumValue . toString ( ) )
611+ . replace ( '{1}' , maximumValue . toString ( ) ) ;
611612 }
612613 }
614+ return errorText ;
613615 }
614616
615617 private isEmptyArray ( value ) : boolean {
0 commit comments