Skip to content

MaybeEmpty and Nullable should have options args #985

Open
@ghost

Description

What is the problem this feature would solve?

t.Nullable t.Empty not support default value.

Value.Parse(t.Object({
  foo: t.Nullable(t.String({ default: null }))
})) // throw  Expected required property.
Value.Parse(t.Object({
  foo: t.Union([t.String(), t.Null()], { default: null })
})) // this works

What is the feature you are proposing to solve the problem?

Allow pass the SchemaOptions to the t.Nullable t.Empty, just like Union<Types extends TSchema[]>(types: [...Types], options?: SchemaOptions): Union;

Nullable: <T extends TSchema>(schema: T, options?: SchemaOptions) => t.Union([schema, t.Null()], options),

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions