diegohaz / bodymen

Body parser middleware for MongoDB, Express and Nodejs (MEN)
Other
47 stars 15 forks source link

Issue with required field type #31

Open SeyTo opened 4 years ago

SeyTo commented 4 years ago

Reproduction: Using a basic express prototype:

router.post(
  '/',
  bodymen.middleware({
    fieldA: { type: String, required: true },
    fieldB: { type: String, required: "randomstring" },
    fieldC: { type: String, required: () => { return false } }
  }),
  (req, res, next) => {
     res.end("done")
  }
)   

All the 3 fields fieldA .. C becomes a required = true case. Calling it will return that all fields are required. I was hoping that atleast 'fieldC' should work as expected. Did I miss anything?