Open tacticalchihuahua opened 4 years ago
This check will return true if the opts[requiredField] property is declared but undefined. Example:
opts[requiredField]
em@xps7390 ~ $ node > const opts = { symbol: undefined, balance: null, identifier: function() {}, decimals: -19, customViewUrl: '' }; undefined > const assetRequiredFields = ['symbol', 'balance', 'identifier', 'decimals', 'customViewUrl'] undefined > assetRequiredFields.forEach((requiredField) => { ... if (!(requiredField in opts)) { ..... throw new Error('missing required field'); ..... } ... }) undefined >
Instead of (!(requiredField in opts)) use (typeof opts[requiredField] === 'undefined'), as well as adding more sophisticated validation for the specific fields.
(!(requiredField in opts))
(typeof opts[requiredField] === 'undefined')
Originally posted by @emeryrose in https://github.com/LeastAuthority/metamask-plugin-beta/pull/1
This check will return true if the
opts[requiredField]
property is declared but undefined. Example:Instead of
(!(requiredField in opts))
use(typeof opts[requiredField] === 'undefined')
, as well as adding more sophisticated validation for the specific fields.Originally posted by @emeryrose in https://github.com/LeastAuthority/metamask-plugin-beta/pull/1