Upgrading Nodes specifically my own

Thanks all. The validation is back in. The ONLY thing that made a difference was the line:


validate:function(v) { return ((v === "") || (RED.validators.number(v)) }

Change to the js file (|| 0) and that oneditprepare made no difference (I’ve put them in as a reminder but commented out) . As I’m not comparing for 0 but only comparing for days 1-7 and months 1-12 I don’t seem to need the rest. While I was on, just to test as would happen to someone else, I added another day.

All appears fine thanks.

Pete

hey,
i came across the same problem now.
do you have also a solution for typedInputs? Because there the validator is depending on it's selected type.

Bonus Question :smiley: -> is it possible to load a json file as default inside? I got a schema field and it should come with a default, but it's really big.

EDIT:
i found a solution :slight_smile:
since nodered 1.3 its possible to serve extra resources in a node
https://nodered.org/docs/creating-nodes/resources

and in the on edit prepare you could do something like this:

 var exampleVal = $("#node-input-example").typedInput('value');
            console.log(exampleVal)

            if (!exampleVal || exampleVal === '{}') {
                $.ajax({
                    url: 'resources/my-node-module-name/example.json',
                    dataType: 'json',
                    success: function (response) {
                        $("#node-input-example").typedInput('value', JSON.stringify(response));
                    }
                });
                
            }

in the js file its easier to load the json file, but also necessary because the graph of the node can be triggered before you execute the onEditPrepare

const EXAMPLE_CONFIG = require('./example.json');
 if (!config.example || config.example === '{}') {
            node.debug("using my default example")
            node.example = JSON.stringify(EXAMPLE_CONFIG);            
        } else {
            node.debug("using example defined by user")
            node.example = config.example;
        }