mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
@@ -15,5 +15,21 @@
|
||||
**/
|
||||
RED.validators = {
|
||||
number: function(){return function(v) { return v!=='' && !isNaN(v);}},
|
||||
regex: function(re){return function(v) { return re.test(v);}}
|
||||
regex: function(re){return function(v) { return re.test(v);}},
|
||||
typedInput: function(ptypeName) { return function(v) {
|
||||
var ptype = $("#node-input-"+ptypeName).val() || this[ptypeName];
|
||||
if (ptype === 'json') {
|
||||
try {
|
||||
JSON.parse(v);
|
||||
return true;
|
||||
} catch(err) {
|
||||
return false;
|
||||
}
|
||||
} else if (ptype === 'flow' || ptype === 'global' ) {
|
||||
return RED.utils.validatePropertyExpression(v);
|
||||
} else if (ptype === 'num') {
|
||||
return /^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(v);
|
||||
}
|
||||
return true;
|
||||
}}
|
||||
};
|
||||
|
Reference in New Issue
Block a user