How to handle checkbox in type('parse.formData').to(...)
I want turn the checkbox into boolean, but the checkbox field only produce "on" when checked, and missing when unchecked...
29 Replies
["'on' | 'off'", "=", "off"] works, but I cannot convert it to boolean
You need to tell ArkType how to convert the string to a boolean. I guess what you want is
but how to embed it with other propertities?
Wdym?
it just dont work
What's the error(s), and what version of ArkType are you ussing?
arktype=2.0.0-beta.5
error is chinese (but it basically mean cannot assign '=' to ....
Do you actually need the default value?
'default?' also doen't work
^ ???
this seems to work nvm, it fails at runtime
runtime error: Default values must be specified on objects like { isAdmin: 'boolean = false' }
Yeah, I just got the same when actually running it
That's probably a bug
If you don't need the default you can remove it and then it works properly
If you do need the default, then I guess the best option is to just make it optional
would work
yes, I think it would be perfect