Fix: Avoid coordinates picked from map not validating.

This commit is contained in:
baldo 2022-09-01 14:03:41 +02:00
parent d135665b60
commit f359509ba0
2 changed files with 62 additions and 64 deletions

View file

@ -41,7 +41,7 @@ const CONSTRAINTS = {
}, },
coords: { coords: {
type: "string", type: "string",
regex: /^(-?[0-9]{1,3}(\.[0-9]{1,15})? -?[0-9]{1,3}(\.[0-9]{1,15})?)$/, regex: /^(-?[0-9]{1,3}(\.[0-9]{1,20})? -?[0-9]{1,3}(\.[0-9]{1,20})?)$/,
optional: true, optional: true,
}, },
monitoring: { monitoring: {

View file

@ -1,142 +1,140 @@
'use strict'; "use strict";
// ATTENTION: Those constraints are no longer the same file as for the server. // ATTENTION: Those constraints are no longer the same file as for the server.
// Make sure changes are also reflected in /server/validation/constraints.ts. // Make sure changes are also reflected in /server/validation/constraints.ts.
(function () { (function () {
var constraints = { const constraints = {
id:{ id: {
type: 'string', type: "string",
regex: /^[1-9][0-9]*$/, regex: /^[1-9][0-9]*$/,
optional: false optional: false,
}, },
token:{ token: {
type: 'string', type: "string",
regex: /^[0-9a-f]{16}$/i, regex: /^[0-9a-f]{16}$/i,
optional: false optional: false,
}, },
node: { node: {
hostname: { hostname: {
type: 'string', type: "string",
regex: /^[-a-z0-9_]{1,32}$/i, regex: /^[-a-z0-9_]{1,32}$/i,
optional: false optional: false,
}, },
key: { key: {
type: 'string', type: "string",
regex: /^([a-f0-9]{64})$/i, regex: /^([a-f0-9]{64})$/i,
optional: true optional: true,
}, },
email: { email: {
type: 'string', type: "string",
regex: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, regex: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
optional: false optional: false,
}, },
nickname: { nickname: {
type: 'string', type: "string",
regex: /^[-a-z0-9_ äöüß]{1,64}$/i, regex: /^[-a-z0-9_ äöüß]{1,64}$/i,
optional: false optional: false,
}, },
mac: { mac: {
type: 'string', type: "string",
regex: /^([a-f0-9]{12}|([a-f0-9]{2}:){5}[a-f0-9]{2}|([a-f0-9]{2}-){5}[a-f0-9]{2})$/i, regex: /^([a-f0-9]{12}|([a-f0-9]{2}:){5}[a-f0-9]{2}|([a-f0-9]{2}-){5}[a-f0-9]{2})$/i,
optional: false optional: false,
}, },
coords: { coords: {
type: 'string', type: "string",
regex: /^(-?[0-9]{1,3}(\.[0-9]{1,15})? -?[0-9]{1,3}(\.[0-9]{1,15})?)$/, regex: /^(-?[0-9]{1,3}(\.[0-9]{1,20})? -?[0-9]{1,3}(\.[0-9]{1,20})?)$/,
optional: true optional: true,
}, },
monitoring: { monitoring: {
type: 'boolean', type: "boolean",
optional: false optional: false,
} },
}, },
nodeFilters: { nodeFilters: {
hasKey: { hasKey: {
type: 'boolean', type: "boolean",
optional: true optional: true,
}, },
hasCoords: { hasCoords: {
type: 'boolean', type: "boolean",
optional: true optional: true,
}, },
onlineState: { onlineState: {
type: 'string', type: "string",
regex: /^(ONLINE|OFFLINE)$/, regex: /^(ONLINE|OFFLINE)$/,
optional: true optional: true,
}, },
monitoringState: { monitoringState: {
type: 'string', type: "string",
regex: /^(disabled|active|pending)$/, regex: /^(disabled|active|pending)$/,
optional: true optional: true,
}, },
site: { site: {
type: 'string', type: "string",
regex: /^[a-z0-9_-]{1,32}$/, regex: /^[a-z0-9_-]{1,32}$/,
optional: true optional: true,
}, },
domain: { domain: {
type: 'string', type: "string",
regex: /^[a-z0-9_-]{1,32}$/, regex: /^[a-z0-9_-]{1,32}$/,
optional: true optional: true,
} },
}, },
rest: { rest: {
list: { list: {
_page: { _page: {
type: 'number', type: "number",
min: 1, min: 1,
optional: true, optional: true,
default: 1 default: 1,
}, },
_perPage: { _perPage: {
type: 'number', type: "number",
min: 1, min: 1,
max: 50, max: 50,
optional: true, optional: true,
default: 20 default: 20,
}, },
_sortDir: { _sortDir: {
type: 'enum', type: "enum",
allowed: ['ASC', 'DESC'], allowed: ["ASC", "DESC"],
optional: true, optional: true,
default: 'ASC' default: "ASC",
}, },
_sortField: { _sortField: {
type: 'string', type: "string",
regex: /^[a-zA-Z0-9_]{1,32}$/, regex: /^[a-zA-Z0-9_]{1,32}$/,
optional: true optional: true,
}, },
q: { q: {
type: 'string', type: "string",
regex: /^[äöüß a-z0-9!#$%&@:.'*+/=?^_`{|}~-]{1,64}$/i, regex: /^[äöüß a-z0-9!#$%&@:.'*+/=?^_`{|}~-]{1,64}$/i,
optional: true optional: true,
} },
} },
} },
} };
var _angular = null let _angular = null;
try { try {
_angular = angular _angular = angular;
} } catch (error) {
catch (error) {
// ReferenceError, as angular is not defined. // ReferenceError, as angular is not defined.
} }
var _module = null let _module = null;
try { try {
_module = module _module = module;
} } catch (error) {
catch (error) {
// ReferenceError, as module is not defined. // ReferenceError, as module is not defined.
} }
if (_angular) { if (_angular) {
angular.module('ffffng').constant('Constraints', constraints) angular.module("ffffng").constant("Constraints", constraints);
} }
if (_module) { if (_module) {
module.exports = constraints module.exports = constraints;
} }
})() })();