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

fix: add optional message to nonNullable schema methods #2119

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

ranquild
Copy link
Contributor

@ranquild ranquild commented Oct 7, 2023

Fixes #2069

Adds an optional msg?: Message argument to nonNullable method on every schema object. The argument is already supported by the base Schema class, and we only need to pass it properly with TypeScript.

Also updates nullable and nonNullable signatures in README.md.

@ranquild
Copy link
Contributor Author

ranquild commented Nov 5, 2023

@jquense could you take a look, please?

@lmarvaud
Copy link

Hello,

It seem that the typing of "notNullable" and "nullable" had been swaped. In Schema.ts, inherited by few validators, only nonNullable takes a parameter.

yup/src/schema.ts

Lines 710 to 715 in 5db2b2f

nullable(): any {
return this.nullability(true);
}
nonNullable(message = locale.notNull): any {
return this.nullability(false, message);
}

Actually wouldn't it be cleaner to add those types in the Schema interface, to avoid code duplication and those type of error ?

@jquense jquense merged commit 9e1df49 into jquense:master Dec 27, 2023
@jquense
Copy link
Owner

jquense commented Dec 27, 2023

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

should all nonNullable receive a msg?: Message property?
3 participants