1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Allow RED.validators.number to allow blank values as valid

This commit is contained in:
Nick O'Leary 2017-01-24 14:28:15 +00:00
parent e27f5d0460
commit 68e0b35364
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
**/ **/
RED.validators = { RED.validators = {
number: function(){return function(v) { return v!=='' && !isNaN(v);}}, number: function(blankAllowed){return function(v) { return (blankAllowed&&v==='') || (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,isConfig) { return function(v) { typedInput: function(ptypeName,isConfig) { return function(v) {
var ptype = $("#node-"+(isConfig?"config-":"")+"input-"+ptypeName).val() || this[ptypeName]; var ptype = $("#node-"+(isConfig?"config-":"")+"input-"+ptypeName).val() || this[ptypeName];