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: {
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,
},
monitoring: {

View file

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