Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to simplify null or undefined checks #471

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion library/src/schemas/nonNullish/nonNullish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function nonNullish<TWrapped extends BaseSchema>(
message,
_parse(input, config) {
// In input is `null` or `undefined`, return schema issue
if (input === null || input === undefined) {
if (input == null) {
return schemaIssue(this, nonNullish, input, config);
}

Expand Down
2 changes: 1 addition & 1 deletion library/src/schemas/nonNullish/nonNullishAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function nonNullishAsync<TWrapped extends BaseSchema | BaseSchemaAsync>(
message,
async _parse(input, config) {
// In input is `null` or `undefined`, return schema issue
if (input === null || input === undefined) {
if (input == null) {
return schemaIssue(this, nonNullishAsync, input, config);
}

Expand Down
2 changes: 1 addition & 1 deletion library/src/schemas/nullish/nullish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function nullish<
_parse(input, config) {
// If input is `null` or `undefined`, return typed schema result or
// override it with default value
if (input === null || input === undefined) {
if (input == null) {
const override = getDefault(this);
if (override === undefined) {
return schemaResult(true, input);
Expand Down
2 changes: 1 addition & 1 deletion library/src/schemas/nullish/nullishAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function nullishAsync<
async _parse(input, config) {
// If input is `null` or `undefined`, return typed schema result or
// override it with default value
if (input === null || input === undefined) {
if (input == null) {
const override = await getDefaultAsync(this);
if (override === undefined) {
return schemaResult(true, input);
Expand Down
Loading