File tree Expand file tree Collapse file tree 5 files changed +14
-0
lines changed
Expand file tree Collapse file tree 5 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 4141 "label_error-space-start" : " Value must not start with a space" ,
4242 "label_error-zero-start" : " Value must not start with a zero" ,
4343 "label_error-dot-end" : " Value must not end with a dot" ,
44+ "label_error-invalid-zero-format" : " Invalid zero value format" ,
4445 "label_delete" : " Delete" ,
4546 "button_cancel" : " Close" ,
4647 "button-upload_file" : " Upload file" ,
Original file line number Diff line number Diff line change 4141 "label_error-space-start" : " Значение не должно начинаться с пробела" ,
4242 "label_error-zero-start" : " Значение не должно начинаться с нуля" ,
4343 "label_error-dot-end" : " Значение не должно заканчиваться точкой" ,
44+ "label_error-invalid-zero-format" : " Неверный формат значения нуля" ,
4445 "label_delete" : " Удалить" ,
4546 "button_cancel" : " Закрыть" ,
4647 "button-upload_file" : " Загрузить файл" ,
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ const getErrorMessages = (): ErrorMessagesType => ({
3030 SPACE_END : i18n ( 'label_error-space-end' ) ,
3131 DOT_END : i18n ( 'label_error-dot-end' ) ,
3232 ZERO_START : i18n ( 'label_error-zero-start' ) ,
33+ INVALID_ZERO_FORMAT : i18n ( 'label_error-invalid-zero-format' ) ,
3334} ) ;
3435
3536export let ErrorMessages : ErrorMessagesType = getErrorMessages ( ) ;
Original file line number Diff line number Diff line change @@ -13,4 +13,5 @@ export interface ErrorMessagesType {
1313 SPACE_END : string ;
1414 DOT_END : string ;
1515 ZERO_START : string ;
16+ INVALID_ZERO_FORMAT : string ;
1617}
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ export interface GetNumberValidatorParams extends CommonValidatorParams {
8484 ignoreIntCheck ?: boolean ;
8585 ignoreDotEnd ?: boolean ;
8686 ignoreZeroStart ?: boolean ;
87+ ignoreInvalidZeroFormat ?: boolean ;
8788}
8889
8990export const getNumberValidator = ( params : GetNumberValidatorParams = { } ) => {
@@ -97,6 +98,7 @@ export const getNumberValidator = (params: GetNumberValidatorParams = {}) => {
9798 ignoreIntCheck,
9899 ignoreDotEnd,
99100 ignoreZeroStart,
101+ ignoreInvalidZeroFormat,
100102 customErrorMessages,
101103 } = params ;
102104
@@ -136,6 +138,14 @@ export const getNumberValidator = (params: GetNumberValidatorParams = {}) => {
136138 ) {
137139 return errorMessages . ZERO_START ;
138140 }
141+
142+ if (
143+ ! ignoreInvalidZeroFormat &&
144+ stringValue . trim ( ) . length > 1 &&
145+ Number ( stringValue . trim ( ) ) === 0
146+ ) {
147+ return errorMessages . INVALID_ZERO_FORMAT ;
148+ }
139149 }
140150
141151 if (
You can’t perform that action at this time.
0 commit comments