You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.log("original",value.KV);constcloned=Value.Clone(value);// clone because value ops can be mutableconsole.log("cloned",cloned.KV);constdefaulted=Value.Default(EnvType,cloned);// initialize defaults for valueconsole.log("defaulted",defaulted.KV);constconverted=Value.Convert(EnvType,defaulted);// convert mismatched types for valueconsole.log("converted",converted.KV);constcleaned=Value.Clean(EnvType,converted);// remove unknown propertiesconsole.log("cleaned",cleaned.KV);constdecoded=Value.Decode(EnvType,cleaned);// run decode transforms (optional)console.log("decoded",decoded.KV);
As you can see, the cloning step seems to corrupt the value. I have tested doing a simple shallow clone in JS via the spread operator, and it preserves the binding correctly, so I am not sure what Value.Clone does that destroys it.
Simply removing the Clone step outputs the following:
If keys returns an empty array, it means the KV object is non-enumerable (so probably can't be cloned), but this seems at odds with you being able to use the spread operator to apply a shallow property clone. This said, if you don't need to Clone the value before applying operations to it, you can use a configurable Parse and omit the Clone operation.
constresult=Value.Parse([// 'Clone', // omit'Clean',// ... and keep these'Default','Convert','Assert','Decode'],schema,value.KV)
Let me know what you see for the above cloned, symbols and keys return values.
Keep me posted
S
I am trying to validate a Cloudflare Worker env context, which binds a ProxyStub instance to it . I have a schema like:
and then I proceed to do the Parse steps:
which outputs:
As you can see, the cloning step seems to corrupt the value. I have tested doing a simple shallow clone in JS via the spread operator, and it preserves the binding correctly, so I am not sure what Value.Clone does that destroys it.
Simply removing the Clone step outputs the following:
which confirms the Clone step is the offender.
The text was updated successfully, but these errors were encountered: