@node-red/nodes 3.1.5 → 3.1.6

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.
@@ -227,34 +227,42 @@
227
227
  name: {value:""},
228
228
  props:{value:[{p:"payload"},{p:"topic",vt:"str"}], validate:function(v, opt) {
229
229
  if (!v || v.length === 0) { return true }
230
+ const errors = []
230
231
  for (var i=0;i<v.length;i++) {
232
+ if (/^\${[^}]+}$/.test(v[i].v)) {
233
+ // Allow ${ENV_VAR} value
234
+ continue
235
+ }
231
236
  if (/msg|flow|global/.test(v[i].vt)) {
232
237
  if (!RED.utils.validatePropertyExpression(v[i].v)) {
233
- return RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v });
238
+ errors.push(RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v }))
234
239
  }
235
240
  } else if (v[i].vt === "jsonata") {
236
241
  try{ jsonata(v[i].v); }
237
242
  catch(e){
238
- return RED._("node-red:inject.errors.invalid-jsonata", { prop: 'msg.'+v[i].p, error: e.message });
243
+ errors.push(RED._("node-red:inject.errors.invalid-jsonata", { prop: 'msg.'+v[i].p, error: e.message }))
239
244
  }
240
245
  } else if (v[i].vt === "json") {
241
246
  try{ JSON.parse(v[i].v); }
242
247
  catch(e){
243
- return RED._("node-red:inject.errors.invalid-json", { prop: 'msg.'+v[i].p, error: e.message });
248
+ errors.push(RED._("node-red:inject.errors.invalid-json", { prop: 'msg.'+v[i].p, error: e.message }))
244
249
  }
245
250
  } else if (v[i].vt === "num"){
246
251
  if (!/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(v[i].v)) {
247
- return RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v });
252
+ errors.push(RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v }))
248
253
  }
249
254
  }
250
255
  }
256
+ if (errors.length > 0) {
257
+ return errors
258
+ }
251
259
  return true;
252
260
  }
253
261
  },
254
262
  repeat: {
255
263
  value:"", validate: function(v, opt) {
256
264
  if ((v === "") ||
257
- (RED.validators.number(v) &&
265
+ (RED.validators.number()(v) &&
258
266
  (v >= 0) && (v <= 2147483))) {
259
267
  return true;
260
268
  }
@@ -263,7 +271,7 @@
263
271
  },
264
272
  crontab: {value:""},
265
273
  once: {value:false},
266
- onceDelay: {value:0.1},
274
+ onceDelay: {value:0.1, validate: RED.validators.number(true)},
267
275
  topic: {value:""},
268
276
  payload: {value:"", validate: RED.validators.typedInput("payloadType", false) },
269
277
  payloadType: {value:"date"},
@@ -23,7 +23,7 @@
23
23
  <dt class="optional">template <span class="property-type">string</span></dt>
24
24
  <dd>由<code>msg.payload</code>填充的模板。如果未在编辑面板中配置,则可以将设为msg的属性。</dd>
25
25
  </dl>
26
- <h3>Outputs</h3>
26
+ <h3>输出</h3>
27
27
  <dl class="message-properties">
28
28
  <dt>msg <span class="property-type">object</span></dt>
29
29
  <dd>由来自传入msg的属性来填充已配置的模板后输出的带有属性的msg。</dd>
@@ -32,7 +32,7 @@
32
32
  <p>默认情况下使用<i><a href="http://mustache.github.io/mustache.5.html" target="_blank">mustache</a></i>格式。如有需要也可以切换其他格式。</p>
33
33
  <p>例如:
34
34
  <pre>Hello {{payload.name}}. Today is {{date}}</pre>
35
- <p>receives a message containing:
35
+ <p>接收一条消息,其中包含:
36
36
  <pre>{
37
37
  date: "Monday",
38
38
  payload: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/nodes",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",