Skip to content

Instantly share code, notes, and snippets.

@snekse
Created October 23, 2018 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snekse/7a0daa3f5c91f604a749d7ff6490a34f to your computer and use it in GitHub Desktop.
Save snekse/7a0daa3f5c91f604a749d7ff6490a34f to your computer and use it in GitHub Desktop.
Testing for a String to just be defined in Yup
// See https://runkit.com/snekse/yup-tests-string-defined
yup.string().min(0).strict(true).nullable(true).notOneOf([undefined]);
// If we want to allow nulls, just add `.nullable(true)`
const schema = yup.string().min(0).strict(true).nullable(true).notOneOf([undefined]);
console.log(schema.isValidSync(""));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment