handling fallback if error for regex

Is there any better way of doing default to undefined when failed one key in an object?
type({
some_key: type("string").pipe((v) => myRegex.test(v) ? v : undefined)
})
type({
some_key: type("string").pipe((v) => myRegex.test(v) ? v : undefined)
})
1 Reply
ssalbdivad
ssalbdivad2mo ago
This looks optimal to me.

Did you find this page helpful?