@justair/justair-library 4.7.15 → 4.7.16-alpha

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justair/justair-library",
3
- "version": "4.7.15",
3
+ "version": "4.7.16-alpha",
4
4
  "description": "JustAir Internal Library",
5
5
 
6
6
  "main": "src/index.js",
@@ -54,6 +54,21 @@ const correctionSchema = mongoose.Schema(
54
54
  required: function () {
55
55
  return this.equationType === 'custom';
56
56
  },
57
+ validate: {
58
+ validator: function(value) {
59
+ if (!value) return true; // Allow empty for non-custom types
60
+ if (value.includes('\0')) return false;
61
+ try {
62
+ const encoder = new TextEncoder();
63
+ const decoder = new TextDecoder('utf-8', { fatal: true });
64
+ decoder.decode(encoder.encode(value));
65
+ return true;
66
+ } catch (e) {
67
+ return false;
68
+ }
69
+ },
70
+ message: 'Equation contains invalid UTF-8 characters'
71
+ },
57
72
  },
58
73
  context: {
59
74
  type: String,
@@ -80,6 +95,21 @@ const correctionHistorySchema = mongoose.Schema(
80
95
  pollutant: {
81
96
  type: String,
82
97
  required: true,
98
+ validate: {
99
+ validator: function(value) {
100
+ // Check for null bytes and validate UTF-8
101
+ if (value.includes('\0')) return false;
102
+ try {
103
+ const encoder = new TextEncoder();
104
+ const decoder = new TextDecoder('utf-8', { fatal: true });
105
+ decoder.decode(encoder.encode(value));
106
+ return true;
107
+ } catch (e) {
108
+ return false;
109
+ }
110
+ },
111
+ message: 'Pollutant contains invalid UTF-8 characters'
112
+ }
83
113
  },
84
114
  oldValue: {
85
115
  type: correctionSchema,