mask() is not recursive
See original GitHub issuehttps://codesandbox.io/s/superstruct-ff5i4-forked-ye1ns?file=/src/index.js
Notice that zzz
is silently removed (expected), but unk
is not (surprising).
import { type, mask, number } from "superstruct";
let data = {
id: 1,
zzz: 444,
some: {
a: 10,
unk: 55
}
};
let Type = type({
id: number(),
some: type({
a: number()
})
});
console.log(JSON.stringify(mask(data, Type)));
// {"id":1,"some":{"a":10,"unk":55}}
P.S. I don’t want to wrap all the type() I have in the code with masked(), because it produces a lot of boilerplate. I assume that the decision of stripping unknown properties is to be made at the caller side (which is likely singular) and not at the definition side (which has way higher cardinality).
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
jQuery Mask not allowing recursive input - Stack Overflow
recursive is meant to repeat any static characters intrinsic to the mask, so for some reason, if there's only one matching character, it...
Read more >Input Mask Guide | imaskjs
Despite mask has been already support esm modules treeshaking did not work on it because of recursive masks and therefore circular dependencies inside....
Read more >Bug in recursion + maxlength in jQuery-Mask-Plugin. - Plunker
As I understand it, it adds the mask on the 9 digits informed, not removing ... Code goes here $(document).ready(function() { $('#noRecursive').mask('0,00', ...
Read more >I cant get samba to set proper permissions on created directories
i have tested adding and removing the directory mask, force directory mode, directory security mode, and the force directory security mode, but the...
Read more >Masks - WinSCP
To make operation non-recursive use exclude mask */ .2. Directory masks are recursive. E.g. mask images/ matches directories ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh yeah, that’s right! So for assert/is, coerce is definitely always = false then.
Here is the PR following the above idea: https://github.com/ianstormtaylor/superstruct/pull/629