-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
That is to say that if x is identified as numerical then the following check should also hold true - else the value should remain of type string:
String( Number( x ) ) === String( x )
For example I have a scenario as follows which leads to an invalid configuration:
foreign_api.verification_token = 000111111 # leading zeros truncated
foreign_api.client_id = 1010101010.10101010101 # too large for float / data loss
I've gotten around this by prefixing an arbitrary token to the value and using the reviver option to remove it, i.e.
foreign_api.verification_token = --000111111
properties.parse('file', {
// ...
reviver: function(key, value){
if(typeof value === 'string')
return value.replace(/^--\s*/, '');
return this.assert();
},
// ...
);
This seems clunky though and I think most use-cases of node-properties would benefit from stable type-coercion.
Metadata
Metadata
Assignees
Labels
No labels