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

Validation for optionals is broken. #10

Closed
JarvisH opened this issue Jun 28, 2023 · 2 comments
Closed

Validation for optionals is broken. #10

JarvisH opened this issue Jun 28, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@JarvisH
Copy link

JarvisH commented Jun 28, 2023

When an optional string schema is processed, the builtInValidationMethod exits early via return.

The loop should not exit early but continue via continue.

This bug currently breaks all validation of schemas with an optional value.

function builtinValidation(env, schema) {
  const errors = [];
  for (const [key, validator] of Object.entries(schema)) {
    try {
      const res = validator(key, env[key]);
      if (typeof res === "undefined") {
        delete process.env[key];
        return; //  should be continue;
      }
      process.env[key] = res;
    } catch (err) {
      errors.push({ key, err });
    }
  }
  if (errors.length) {
    throw new Error(errorReporter$1(errors));
  }
}
@Julien-R44
Copy link
Owner

Ooops,was introduced with #9 . I didn't catch this

@Julien-R44
Copy link
Owner

Released fix with 0.2.4. Thanks for the issue !

@Julien-R44 Julien-R44 self-assigned this Jun 28, 2023
@Julien-R44 Julien-R44 added the bug Something isn't working label Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants