Skip to content

Commit 8f2f5ce

Browse files
committed
fix(validation): validate lat/lng max/min values in editor
1 parent 1d170cf commit 8f2f5ce

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/editor/util/validation.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,27 @@ export function validate (type, required, name, value, entities, id) {
6565
} else {
6666
return false
6767
}
68-
case 'TIME':
6968
case 'LATITUDE':
69+
isNotValid = required && (value === null || typeof value === 'undefined')
70+
if (value > 90 || value < -90) {
71+
isNotValid = true
72+
}
73+
if (isNotValid) {
74+
return {field: name, invalid: isNotValid}
75+
} else {
76+
return false
77+
}
7078
case 'LONGITUDE':
7179
isNotValid = required && (value === null || typeof value === 'undefined')
80+
if (value > 180 || value < -180) {
81+
isNotValid = true
82+
}
7283
if (isNotValid) {
7384
return {field: name, invalid: isNotValid}
7485
} else {
7586
return false
7687
}
88+
case 'TIME':
7789
case 'NUMBER':
7890
isNotValid = required && (value === null || typeof value === 'undefined')
7991
if (isNotValid) {

0 commit comments

Comments
 (0)