File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
src/converters/convertAction Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ All notable changes to the library will be documented in this file.
55## vX.X.X (Month DD, YYYY)
66
77- Add support for ` examples ` action
8+ - Add support for ` integer ` when used with ` minValue ` and ` maxValue ` actions (pull request #1367 )
89- Fix conversion of ` exactOptional ` object properties (pull request #1220 )
910- Fix conversion of ` variant ` to use ` oneOf ` instead of ` anyOf ` (pull request #1193 )
1011
Original file line number Diff line number Diff line change @@ -460,6 +460,19 @@ describe('convertAction', () => {
460460 } ) ;
461461 } ) ;
462462
463+ test ( 'should convert max value action for integers' , ( ) => {
464+ expect (
465+ convertAction (
466+ { type : 'integer' } ,
467+ v . maxValue < v . ValueInput , 100 > ( 100 ) ,
468+ undefined
469+ )
470+ ) . toStrictEqual ( {
471+ type : 'integer' ,
472+ maximum : 100 ,
473+ } ) ;
474+ } ) ;
475+
463476 test ( 'should throw error for max value action with invalid type' , ( ) => {
464477 const action = v . maxValue < v . ValueInput , 3 > ( 3 ) ;
465478 const error1 =
@@ -629,6 +642,19 @@ describe('convertAction', () => {
629642 } ) ;
630643 } ) ;
631644
645+ test ( 'should convert min value action for integers' , ( ) => {
646+ expect (
647+ convertAction (
648+ { type : 'integer' } ,
649+ v . minValue < v . ValueInput , 1 > ( 1 ) ,
650+ undefined
651+ )
652+ ) . toStrictEqual ( {
653+ type : 'integer' ,
654+ minimum : 1 ,
655+ } ) ;
656+ } ) ;
657+
632658 test ( 'should throw error for min value action with invalid type' , ( ) => {
633659 const action = v . minValue < v . ValueInput , 3 > ( 3 ) ;
634660 const error1 =
Original file line number Diff line number Diff line change @@ -261,7 +261,7 @@ export function convertAction(
261261 }
262262
263263 case 'max_value' : {
264- if ( jsonSchema . type !== 'number' ) {
264+ if ( jsonSchema . type !== 'number' && jsonSchema . type !== 'integer' ) {
265265 errors = addError (
266266 errors ,
267267 `The "max_value" action is not supported on type "${ jsonSchema . type } ".`
@@ -313,7 +313,7 @@ export function convertAction(
313313 }
314314
315315 case 'min_value' : {
316- if ( jsonSchema . type !== 'number' ) {
316+ if ( jsonSchema . type !== 'number' && jsonSchema . type !== 'integer' ) {
317317 errors = addError (
318318 errors ,
319319 `The "min_value" action is not supported on type "${ jsonSchema . type } ".`
You can’t perform that action at this time.
0 commit comments