@@ -95,7 +95,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
95
95
96
96
const labelEl = < label className = { ( required ) ? styles . fieldRequired + ' ' + styles . fieldLabel : styles . fieldLabel } > { labelText } </ label > ;
97
97
const errorText = this . getRequiredErrorText ( ) ;
98
- const errorTextforNumber = this . getnumberErrorText ( ) ;
98
+ const errorTextforNumber = this . getNumberErrorText ( ) ;
99
99
const errorTextEl = < text className = { styles . errormessage } > { errorText } </ text > ;
100
100
const descriptionEl = < text className = { styles . fieldDescription } > { description } </ text > ;
101
101
const hasImage = ! ! changedValue ;
@@ -139,7 +139,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
139
139
value = { value }
140
140
className = { styles . fieldDisplay }
141
141
onChange = { ( newText ) => { this . onChange ( newText ) ; return newText ; } }
142
- isEditMode = { ! disabled } />
142
+ isEditMode = { ! disabled } />
143
143
{ descriptionEl }
144
144
{ errorTextEl }
145
145
</ div > ;
@@ -588,28 +588,30 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
588
588
const {
589
589
changedValue
590
590
} = 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 ;
592
592
}
593
593
594
- private getnumberErrorText = ( ) : string => {
594
+ private getNumberErrorText = ( ) : string => {
595
595
const {
596
596
changedValue
597
597
} = this . state ;
598
- const {
598
+ const {
599
599
maximumValue,
600
600
minimumValue,
601
601
showAsPercentage
602
602
} = this . props ;
603
603
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 ( ) ) ;
611
612
}
612
613
}
614
+ return errorText ;
613
615
}
614
616
615
617
private isEmptyArray ( value ) : boolean {
0 commit comments