@@ -15,17 +15,20 @@ function validatePost (req, res) {
15
15
req . body . exchange_after_x_days -= 0 ;
16
16
req . body . timeout_after_x_seconds -= 0 ;
17
17
18
- if ( ! check . number ( req . body . exchange_after_x_ignition_cycles ) ) {
19
- return setError ( "exchange_after_x_ignition_cycles required" ) ;
18
+ if ( ! check . number ( req . body . exchange_after_x_ignition_cycles ) ||
19
+ ( check . number ( req . body . exchange_after_x_ignition_cycles ) && req . body . exchange_after_x_ignition_cycles > 255 ) ) {
20
+ return setError ( "exchange_after_x_ignition_cycles required and should not exceed 255" ) ;
20
21
}
21
22
if ( ! check . number ( req . body . exchange_after_x_kilometers ) ) {
22
23
return setError ( "exchange_after_x_kilometers required" ) ;
23
24
}
24
- if ( ! check . number ( req . body . exchange_after_x_days ) ) {
25
- return setError ( "exchange_after_x_days required" ) ;
25
+ if ( ! check . number ( req . body . exchange_after_x_days ) ||
26
+ ( check . number ( req . body . exchange_after_x_days ) && req . body . exchange_after_x_days > 255 ) ) {
27
+ return setError ( "exchange_after_x_days required and should not exceed 255" ) ;
26
28
}
27
- if ( ! check . number ( req . body . timeout_after_x_seconds ) ) {
28
- return setError ( "timeout_after_x_seconds required" ) ;
29
+ if ( ! check . number ( req . body . timeout_after_x_seconds ) ||
30
+ ( check . number ( req . body . timeout_after_x_seconds ) && req . body . timeout_after_x_seconds > 65535 ) ) {
31
+ return setError ( "timeout_after_x_seconds required and should not exceed 65535" ) ;
29
32
}
30
33
if ( ! check . array ( req . body . seconds_between_retries ) ) {
31
34
return setError ( "seconds_between_retries required" ) ;
@@ -58,26 +61,33 @@ function validatePost (req, res) {
58
61
req . body . notifications_per_minute_by_priority . COMMUNICATION -= 0 ;
59
62
req . body . notifications_per_minute_by_priority . NORMAL -= 0 ;
60
63
req . body . notifications_per_minute_by_priority . NONE -= 0 ;
61
- if ( ! check . number ( req . body . notifications_per_minute_by_priority . EMERGENCY ) ) {
62
- return setError ( "EMERGENCY notification count required" ) ;
64
+ if ( ! check . number ( req . body . notifications_per_minute_by_priority . EMERGENCY ) ||
65
+ ( check . number ( req . body . notifications_per_minute_by_priority . EMERGENCY ) && req . body . notifications_per_minute_by_priority . EMERGENCY > 255 ) ) {
66
+ return setError ( "EMERGENCY notification count required and should not exceed 255" ) ;
63
67
}
64
- if ( ! check . number ( req . body . notifications_per_minute_by_priority . NAVIGATION ) ) {
65
- return setError ( "NAVIGATION notification count required" ) ;
68
+ if ( ! check . number ( req . body . notifications_per_minute_by_priority . NAVIGATION ) ||
69
+ ( check . number ( req . body . notifications_per_minute_by_priority . NAVIGATION ) && req . body . notifications_per_minute_by_priority . NAVIGATION > 255 ) ) {
70
+ return setError ( "NAVIGATION notification count required and should not exceed 255" ) ;
66
71
}
67
- if ( ! check . number ( req . body . notifications_per_minute_by_priority . PROJECTION ) ) {
68
- return setError ( "PROJECTION notification count required" ) ;
72
+ if ( ! check . number ( req . body . notifications_per_minute_by_priority . PROJECTION ) ||
73
+ ( check . number ( req . body . notifications_per_minute_by_priority . PROJECTION ) && req . body . notifications_per_minute_by_priority . PROJECTION > 255 ) ) {
74
+ return setError ( "PROJECTION notification count required and should not exceed 255" ) ;
69
75
}
70
- if ( ! check . number ( req . body . notifications_per_minute_by_priority . VOICECOM ) ) {
71
- return setError ( "VOICECOM notification count required" ) ;
76
+ if ( ! check . number ( req . body . notifications_per_minute_by_priority . VOICECOM ) ||
77
+ ( check . number ( req . body . notifications_per_minute_by_priority . VOICECOM ) && req . body . notifications_per_minute_by_priority . VOICECOM > 255 ) ) {
78
+ return setError ( "VOICECOM notification count required and should not exceed 255" ) ;
72
79
}
73
- if ( ! check . number ( req . body . notifications_per_minute_by_priority . COMMUNICATION ) ) {
74
- return setError ( "COMMUNICATION notification count required" ) ;
80
+ if ( ! check . number ( req . body . notifications_per_minute_by_priority . COMMUNICATION ) ||
81
+ ( check . number ( req . body . notifications_per_minute_by_priority . COMMUNICATION ) && req . body . notifications_per_minute_by_priority . COMMUNICATION > 255 ) ) {
82
+ return setError ( "COMMUNICATION notification count required and should not exceed 255" ) ;
75
83
}
76
- if ( ! check . number ( req . body . notifications_per_minute_by_priority . NORMAL ) ) {
77
- return setError ( "NORMAL notification count required" ) ;
84
+ if ( ! check . number ( req . body . notifications_per_minute_by_priority . NORMAL ) ||
85
+ ( check . number ( req . body . notifications_per_minute_by_priority . NORMAL ) && req . body . notifications_per_minute_by_priority . NORMAL > 255 ) ) {
86
+ return setError ( "NORMAL notification count required and should not exceed 255" ) ;
78
87
}
79
- if ( ! check . number ( req . body . notifications_per_minute_by_priority . NONE ) ) {
80
- return setError ( "NONE notification count required" ) ;
88
+ if ( ! check . number ( req . body . notifications_per_minute_by_priority . NONE ) ||
89
+ ( check . number ( req . body . notifications_per_minute_by_priority . NONE ) && req . body . notifications_per_minute_by_priority . NONE > 255 ) ) {
90
+ return setError ( "NONE notification count required and should not exceed 255" ) ;
81
91
}
82
92
83
93
req . body . subtle_notifications_per_minute_by_priority . EMERGENCY -= 0 ;
@@ -87,26 +97,33 @@ function validatePost (req, res) {
87
97
req . body . subtle_notifications_per_minute_by_priority . COMMUNICATION -= 0 ;
88
98
req . body . subtle_notifications_per_minute_by_priority . NORMAL -= 0 ;
89
99
req . body . subtle_notifications_per_minute_by_priority . NONE -= 0 ;
90
- if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . EMERGENCY ) ) {
91
- return setError ( "Subtle EMERGENCY notification count required" ) ;
100
+ if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . EMERGENCY ) ||
101
+ ( check . number ( req . body . subtle_notifications_per_minute_by_priority . EMERGENCY ) && req . body . subtle_notifications_per_minute_by_priority . EMERGENCY > 255 ) ) {
102
+ return setError ( "Subtle EMERGENCY notification count required and should not exceed 255" ) ;
92
103
}
93
- if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . NAVIGATION ) ) {
94
- return setError ( "Subtle NAVIGATION notification count required" ) ;
104
+ if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . NAVIGATION ) ||
105
+ ( check . number ( req . body . subtle_notifications_per_minute_by_priority . NAVIGATION ) && req . body . subtle_notifications_per_minute_by_priority . NAVIGATION > 255 ) ) {
106
+ return setError ( "Subtle NAVIGATION notification count required and should not exceed 255" ) ;
95
107
}
96
- if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . PROJECTION ) ) {
97
- return setError ( "Subtle PROJECTION notification count required" ) ;
108
+ if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . PROJECTION ) ||
109
+ ( check . number ( req . body . subtle_notifications_per_minute_by_priority . PROJECTION ) && req . body . subtle_notifications_per_minute_by_priority . PROJECTION > 255 ) ) {
110
+ return setError ( "Subtle PROJECTION notification count required and should not exceed 255" ) ;
98
111
}
99
- if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . VOICECOM ) ) {
100
- return setError ( "Subtle VOICECOM notification count required" ) ;
112
+ if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . VOICECOM ) ||
113
+ ( check . number ( req . body . subtle_notifications_per_minute_by_priority . VOICECOM ) && req . body . subtle_notifications_per_minute_by_priority . VOICECOM > 255 ) ) {
114
+ return setError ( "Subtle VOICECOM notification count required and should not exceed 255" ) ;
101
115
}
102
- if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . COMMUNICATION ) ) {
103
- return setError ( "Subtle COMMUNICATION notification count required" ) ;
116
+ if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . COMMUNICATION ) ||
117
+ ( check . number ( req . body . subtle_notifications_per_minute_by_priority . COMMUNICATION ) && req . body . subtle_notifications_per_minute_by_priority . COMMUNICATION > 255 ) ) {
118
+ return setError ( "Subtle COMMUNICATION notification count required and should not exceed 255" ) ;
104
119
}
105
- if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . NORMAL ) ) {
106
- return setError ( "Subtle NORMAL notification count required" ) ;
120
+ if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . NORMAL ) ||
121
+ ( check . number ( req . body . subtle_notifications_per_minute_by_priority . NORMAL ) && req . body . subtle_notifications_per_minute_by_priority . NORMAL > 255 ) ) {
122
+ return setError ( "Subtle NORMAL notification count required and should not exceed 255" ) ;
107
123
}
108
- if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . NONE ) ) {
109
- return setError ( "Subtle NONE notification count required" ) ;
124
+ if ( ! check . number ( req . body . subtle_notifications_per_minute_by_priority . NONE ) ||
125
+ ( check . number ( req . body . subtle_notifications_per_minute_by_priority . NONE ) && req . body . subtle_notifications_per_minute_by_priority . NONE > 255 ) ) {
126
+ return setError ( "Subtle NONE notification count required and should not exceed 255" ) ;
110
127
}
111
128
return ;
112
129
0 commit comments