Validate Record values with morphs
Is it possible to do more advanced validation on Records? Ideally I'd like to apply any morph to each item in a Record.
In the
???
place, I'd like to validate against nullNumber
, is it possible?6 Replies
Have you tried using a scope? Something like
Yeah a record is a Type like any other the value could be anything.
In a case like this, you could create your record using
type.Record("string", nullNumber)
Ah, that's nice, I knew it was possible, just didn't know the syntax. 🙂
Record is common so it is attached directly to
type
but all keywords are available under type.keywords
, so you can invoke any generic from thereAgain, it's just amazing how flexible and convenient you've made this
I'm gonna put Arktype to good use in an upcoming large project
Thank you! It really helps that under the hood, all types work the same way so you can always compose them without worrying about what form is allowed where
Even the output of the new
match
expression will be a union you can compose with any other Type!