Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions library/src/schemas/looseObject/looseObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export function looseObject(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -177,7 +178,8 @@ export function looseObject(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
6 changes: 4 additions & 2 deletions library/src/schemas/looseObject/looseObjectAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export function looseObjectAsync(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -199,7 +200,8 @@ export function looseObjectAsync(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
6 changes: 4 additions & 2 deletions library/src/schemas/object/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export function object(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -180,7 +181,8 @@ export function object(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
6 changes: 4 additions & 2 deletions library/src/schemas/object/objectAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export function objectAsync(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -202,7 +203,8 @@ export function objectAsync(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
6 changes: 4 additions & 2 deletions library/src/schemas/objectWithRest/objectWithRest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ export function objectWithRest(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -200,7 +201,8 @@ export function objectWithRest(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
6 changes: 4 additions & 2 deletions library/src/schemas/objectWithRest/objectWithRestAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export function objectWithRestAsync(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -250,7 +251,8 @@ export function objectWithRestAsync(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
6 changes: 4 additions & 2 deletions library/src/schemas/strictObject/strictObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ export function strictObject(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -173,7 +174,8 @@ export function strictObject(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
6 changes: 4 additions & 2 deletions library/src/schemas/strictObject/strictObjectAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export function strictObjectAsync(
key in input ||
((valueSchema.type === 'exact_optional' ||
valueSchema.type === 'optional' ||
valueSchema.type === 'nullish') &&
valueSchema.type === 'nullish' ||
valueSchema.type === 'undefinedable') &&
// @ts-expect-error
valueSchema.default !== undefined)
) {
Expand Down Expand Up @@ -195,7 +196,8 @@ export function strictObjectAsync(
} else if (
valueSchema.type !== 'exact_optional' &&
valueSchema.type !== 'optional' &&
valueSchema.type !== 'nullish'
valueSchema.type !== 'nullish' &&
valueSchema.type !== 'undefinedable'
) {
_addIssue(this, 'key', dataset, config, {
input: undefined,
Expand Down
3 changes: 2 additions & 1 deletion library/src/schemas/variant/variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export function variant(
).issues
: discriminatorSchema.type !== 'exact_optional' &&
discriminatorSchema.type !== 'optional' &&
discriminatorSchema.type !== 'nullish'
discriminatorSchema.type !== 'nullish' &&
discriminatorSchema.type !== 'undefinedable'
) {
keysAreValid = false;

Expand Down
3 changes: 2 additions & 1 deletion library/src/schemas/variant/variantAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export function variantAsync(
).issues
: discriminatorSchema.type !== 'exact_optional' &&
discriminatorSchema.type !== 'optional' &&
discriminatorSchema.type !== 'nullish'
discriminatorSchema.type !== 'nullish' &&
discriminatorSchema.type !== 'undefinedable'
) {
keysAreValid = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export function convertSchema(
for (const key in valibotSchema.entries) {
const entry = valibotSchema.entries[key] as SchemaOrPipe;
jsonSchema.properties[key] = convertSchema({}, entry, config, context);
if (entry.type !== 'nullish' && entry.type !== 'optional') {
if (entry.type !== 'nullish' && entry.type !== 'optional' && entry.type !== 'undefinedable') {
jsonSchema.required.push(key);
}
}
Expand Down