@opengis/fastify-table 2.4.8 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AA+GA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,IAAS,EACT,MAAW,GACZ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,OAMA"}
1
+ {"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AAkIA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,IAAS,EACT,MAAW,GACZ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,OAMA"}
@@ -2,6 +2,11 @@ import config from "../../../../config.js";
2
2
  /* eslint-disable no-console */
3
3
  // eslint-disable-next-line no-control-regex
4
4
  const emailReg = /(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/g;
5
+ function isNumeric(value) {
6
+ if (value === null || value === "")
7
+ return false;
8
+ return Number.isFinite(Number(value));
9
+ }
5
10
  function checkField(key, val, options, idx, body) {
6
11
  const type = options?.type?.toLowerCase?.();
7
12
  const isrequired = options?.validators?.includes?.("required");
@@ -26,6 +31,20 @@ function checkField(key, val, options, idx, body) {
26
31
  };
27
32
  }
28
33
  }
34
+ else if (type === "number") {
35
+ // required + empty
36
+ if (isrequired && !isNumeric(val)) {
37
+ return { error: "invalid value", key, idx };
38
+ }
39
+ if (isNumeric(val)) {
40
+ if (isNumeric(options.min) && +val < +options.min) {
41
+ return { error: "Number out of range", key, idx };
42
+ }
43
+ if (isNumeric(options.max) && +val > +options.max) {
44
+ return { error: "Number out of range", key, idx };
45
+ }
46
+ }
47
+ }
29
48
  else if (isrequired && !val) {
30
49
  if (options?.conditions) {
31
50
  const allowed = typeof options?.conditions?.[2] === "string" &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.4.8",
3
+ "version": "2.4.9",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [