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

Optional fields are null #7

Open
boldt opened this issue Jul 7, 2015 · 0 comments
Open

Optional fields are null #7

boldt opened this issue Jul 7, 2015 · 0 comments

Comments

@boldt
Copy link

boldt commented Jul 7, 2015

Imagine the following example:

var paperwork = require('paperwork');

var ScenarioSchemaPatch = {
    title: paperwork.optional(String),
    text: paperwork.optional(String)
};

var post = { text : "data", unknown_field : "foo"};

paperwork(ScenarioSchemaPatch, post, function (err, validated) {
  if (err) {
    console.error("Error",err);
  } else {
    console.log("JSON", validated);
  }
});

It returns:

JSON { title: null, text: 'data' }

Why is the title set to null, even if it was set to optional?

@boldt boldt changed the title Optional field are null Optional fields are null Jul 7, 2015
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

No branches or pull requests

1 participant