Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Schema Validation with Proxies possible error #49
Comments
|
There is a code on p. 195 (6.1.3 Schema Validation with Proxies) that isnt working for me.
const validations = new Map()const validator = {set(target, key, value) {if (validations.has(key)) {return validations[key](value)}return Reflect.set(target, key, value)}}I suggest to change
return validations[key](value)tovalidations(key)(value), because of:Mapobject dont support accessing through[], only throughgetmethod.returnresult of validation, we dont actually reach setting value attarget[key]. If we just validate value by direct method call ofvalidationsobject, as I suggesting, we throw error in that method if value isnt valid, or bypass this method in case of valid value and reach setting the value inReflect.set.