GithubHelp home page GithubHelp logo

paperwork's People

Contributors

andrewjli avatar floby avatar lperrin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

paperwork's Issues

Optional fields are null

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?

Validate a `required` array of objects

Just a question. How do I validate an array of objects that are required. You show in the example how to validate an array of objects that is optional, but not required. Any help would be appreciated!

Asynchronous custom validators

I have a custom validator that is asynchronous (it interfaces with the database). Is it possible to integrate said validator with paperwork? Thanks in advance.

Clone and Performances ?

Hello,

Is paperwork clone all objects or just when there is too much fields ?

For example if I have this schema

var schema = { age: Number };

And this data

var data = { age: 20, firstname: 'Jean' }

The output will be :

{age: 20}

So, if I well understand, you have created a new "cleaned" object during validation.
But what happened if in data there is no extra fields ? Is object also cleaned ? What is the performance cost ?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.