@@ -76,41 +76,39 @@ const createRangeOrderValidator =
7676 reason : MSG_MIN_GREATER_THAN_MAX ,
7777 } ;
7878
79- type BreakpointValidators = {
80- up : ( ...args : any [ ] ) => ValidationResult [ ] ;
81- down : ( ...args : any [ ] ) => ValidationResult [ ] ;
82- between : ( ...args : any [ ] ) => ValidationResult [ ] ;
83- only : ( ...args : any [ ] ) => ValidationResult [ ] ;
84- } ;
85-
8679export const buildBreakpointValidators = < T extends Values > (
8780 theme : StyledBreakpointsTheme < T >
88- ) : BreakpointValidators => {
81+ ) => {
8982 const ctx = buildContext ( theme ) ;
9083 const validateBreakpointExist = createExistenceValidator ( ctx ) ;
9184 const validateZeroUpperBound = createZeroBoundValidator ( ctx ) ;
9285 const validateRangeOrder = createRangeOrderValidator ( ctx ) ;
9386
9487 return {
95- up : ( min : string , orientation ?: string ) => [
96- validateBreakpointExist ( min ) ,
97- validateOrientation ( orientation ) ,
98- ] ,
99- down : ( max : string , orientation ?: string ) => [
100- validateBreakpointExist ( max ) ,
101- validateZeroUpperBound ( max ) ,
102- validateOrientation ( orientation ) ,
88+ up : ( ...args : any [ ] ) => [
89+ validateBreakpointExist ( args [ 0 ] ) ,
90+ validateOrientation ( args [ 1 ] ) ,
10391 ] ,
104- between : ( min : string , max : string , orientation ?: string ) => [
105- validateRangeArity ( min , max ) ,
106- validateBreakpointExist ( min , 'First breakpoint' ) ,
107- validateBreakpointExist ( max , 'Second breakpoint' ) ,
108- validateRangeOrder ( min , max ) ,
109- validateOrientation ( orientation ) ,
92+ down : ( ...args : any [ ] ) => [
93+ validateBreakpointExist ( args [ 0 ] ) ,
94+ validateZeroUpperBound ( args [ 0 ] ) ,
95+ validateOrientation ( args [ 1 ] ) ,
11096 ] ,
111- only : ( key : string , orientation ?: string ) => [
112- validateBreakpointExist ( key ) ,
113- validateOrientation ( orientation ) ,
97+ between : ( ...args : any [ ] ) => {
98+ const min = args [ 0 ] ;
99+ const max = args [ 1 ] ;
100+
101+ return [
102+ validateRangeArity ( min , max ) ,
103+ validateBreakpointExist ( min , 'First breakpoint' ) ,
104+ validateBreakpointExist ( max , 'Second breakpoint' ) ,
105+ validateRangeOrder ( min , max ) ,
106+ validateOrientation ( args [ 2 ] ) ,
107+ ] ;
108+ } ,
109+ only : ( ...args : any [ ] ) => [
110+ validateBreakpointExist ( args [ 0 ] ) ,
111+ validateOrientation ( args [ 1 ] ) ,
114112 ] ,
115113 } ;
116114} ;
0 commit comments