The default value of a property can be defined as a function. If such a function returns for example a random value, it is not helpful to extract a random value as the default value for the web-types definition. It would be better to see the function instead to get an idea of what kind of value will be returned.
Therefore, default value functions are returned as a string, if they do not initialize an empty Array or Object.
Examplesdefault: () => String(Math.round(Math.random() * 10000000))
should be extracted as "default": "() => { return String(Math.round(Math.random() * 10000000)); }"
instead of "default": "\"9489845\""
default: () => String(_id++)
should be extracted as "default": "() => { return String(_id++); }"
instead of "default": "\"1\""
default: () => [] or default: () => ({})
should be extracted as "default": "[]" or "default": "{}"
Open Question
I am not sure, how the changes affect the following lines:
// discard GUID name from quasar framework
&& (value.match(/[a-z0-9]+-[a-z0-9]+-[a-z0-9]+-[a-z0-9]+-[a-z0-9]+/)
// and date from vuetify framework
|| value.match(/[0-9]+-[0-9]+-[0-9]+/)))) {
If the GUID and date are returned in functions, this code will not work anymore, right? I was searching for such a date default value in the vuetify code but could not find anything.
Maybe we can store value and value() as separate variables and check if one of them matches the given RegEx?
The default value of a property can be defined as a function. If such a function returns for example a random value, it is not helpful to extract a random value as the default value for the web-types definition. It would be better to see the function instead to get an idea of what kind of value will be returned.
Therefore, default value functions are returned as a string, if they do not initialize an empty Array or Object.
Examples
default: () => String(Math.round(Math.random() * 10000000))
should be extracted as"default": "() => { return String(Math.round(Math.random() * 10000000)); }"
instead of"default": "\"9489845\""
default: () => String(_id++)
should be extracted as"default": "() => { return String(_id++); }"
instead of"default": "\"1\""
default: () => []
ordefault: () => ({})
should be extracted as"default": "[]"
or"default": "{}"
Open Question I am not sure, how the changes affect the following lines:
If the GUID and date are returned in functions, this code will not work anymore, right? I was searching for such a date default value in the vuetify code but could not find anything. Maybe we can store
value
andvalue()
as separate variables and check if one of them matches the given RegEx?