z0mt3c / node-restify-validation

Validation for REST Services built with node-restify in node.js
MIT License
91 stars 49 forks source link

Can't see variables submitted via application/x-www-form-urlencoded #68

Open SilentImp opened 7 years ago

SilentImp commented 7 years ago

I am keep getting 409 Conflict

{
"code": "InvalidArgument",
"message": "name (MISSING): Field is required, email (INVALID): Invalid email"
}

if I am sending data with

Content-Type: application/x-www-form-urlencoded

name=Anton&email=boogagoogle.co
import restify from 'restify';
import restifyValidation from 'node-restify-validation';
const server = restify.createServer();
server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());
server.use(restifyValidation.validationPlugin());
server.post({
  url: '/',
  validation: {
    queries: {
      name: {
        isRequired: true,
      },
      email: {
        isEmail: true
      },
    },
  }}, async (req, res, next)=>{});

I have tried content instead of queries also. What gone wrong?

gchauvet commented 7 years ago

What is your restify version ?

knudsenjeremy commented 6 years ago

Was there ever resolution or a workaround for this issue?

gchauvet commented 6 years ago

Hi,

Email is invalid. Try with foo@boogagoogle.co seems to be ok. Take a look in unit tests in this project.