Skip to content
Discussion options

You must be logged in to vote

Hi @isimmons, it looks like what you're after is onUndeclaredKey:

const userSchema = type({
    name: "string",
    email: "email"
}).onUndeclaredKey("delete");

const parsed = useSchema({name: "fred", email: "[email protected]", private: "something private");
console.log(parsed); // doesn't have the "private" key

This can be found on the docs here: https://arktype.io/docs/type-api

There's also a shorthand where instead of .onUndeclaredKey("delete") you can do "+": "delete" within the schema itself, i.e.

const userSchema = type({
    name: "string",
    email": "email",
    "+": "delete"
});

And this can be configured per-type as shown above, or if you want this to apply to all created types…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@isimmons
Comment options

@ssalbdivad
Comment options

Answer selected by isimmons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants