@@ -95,6 +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 ( ) ;
9899 const errorTextEl = < text className = { styles . errormessage } > { errorText } </ text > ;
99100 const descriptionEl = < text className = { styles . fieldDescription } > { description } </ text > ;
100101 const hasImage = ! ! changedValue ;
@@ -271,7 +272,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
271272 onChange = { ( e , newText ) => { this . onChange ( newText ) ; } }
272273 disabled = { disabled }
273274 onBlur = { this . onBlur }
274- errorMessage = { errorText } />
275+ errorMessage = { errorTextforNumber } />
275276 { descriptionEl }
276277 </ div > ;
277278
@@ -590,6 +591,27 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
590591 return ( changedValue === undefined || changedValue === '' || changedValue === null || this . isEmptyArray ( changedValue ) ) && this . props . required ? strings . DynamicFormRequiredErrorMessage : null ;
591592 }
592593
594+ private getnumberErrorText = ( ) : string => {
595+ const {
596+ changedValue
597+ } = this . state ;
598+ const {
599+ maximumValue,
600+ minimumValue,
601+ showAsPercentage
602+ } = this . props ;
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 ( ) ) ;
611+ }
612+ }
613+ }
614+
593615 private isEmptyArray ( value ) : boolean {
594616 return Array . isArray ( value ) && value . length === 0 ;
595617 }
0 commit comments