-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Is your feature request related to a problem? Please describe.
Having to write itz.AsOptionalNumber
all the time is really cumbersome, there needs to be a simpler and cleaner way.
Describe the solution you'd like
The solution would be to introduce string literals back and be able to use 'as number?'
as if it was a validator. Internally the same validators would still be used.
Describe alternatives you've considered
Really I don't think there's any simpler than that.
Additional context
The new possible validation values would be:
- Primitives:
'string'
,'number'
,'object'
,'undefined'
,'null'
, and'boolean'
- Primitive Arrays:
'string[]'
,'number[]'
,'object[]'
,'undefined[]'
,'null[]'
, and'boolean[]'
Before
const Headers = itz.A({
UserDomain: itz.String,
WholeFamily: itz.AsOptionalBoolean,
SomethingElse: itz.Either(itz.String, itz.AsNumber, itz.Undefined),
});
After
const Headers = itz.A({
UserDomain: 'string',
WholeFamily: 'as boolean?',
SomethingElse: itz.Either('string', 'as number', 'undefined'),
});