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

Request params layer validation #845

Assignees
Labels
issue: feature request Issue suggesting a new feature severity: medium If it breaks the basic use of the product but can be worked around

Comments

@tranthebao
Copy link

Node.js version:
v8.9.4
npm version:
v5.6.0
Strapi version:
3.0.0-alpha.11.1
Operating system:
windows 8.1 64bit

Do you want to request a feature or report a bug?
I' want to validated when use to rest api.
When use action in controller ("Add") then input value >50(role settings is 30) and post it.
Result not return validate. How to support for me.
Thank you a lot of.
What is the current behavior?
I'm not attach validate in model when rest api.
If the current behavior is a bug, please provide the steps to reproduce the problem
{
"connection": "default",
"collectionName": "book",
"info": {
"name": "book",
"description": ""
},
"options": {
"increments": true,
"timestamps": true,
"comment": ""
},
"attributes": {
"title": {
"maxLength": 50,
"multiple": false,
"type": "string",
"unique": true,
"required": true
},
"author": {
"model": "author",
"via": "book"
}
}
}
when use ajax rest api.
title input is null but action "add" continue insert to db.
What is the expected behavior?
I'm want to validated model when action rest api.

@lauriejim lauriejim self-assigned this Mar 26, 2018
@lauriejim lauriejim added issue: enhancement Issue suggesting an enhancement to an existing feature severity: medium If it breaks the basic use of the product but can be worked around status: need more informations 🤔 labels Mar 26, 2018
@lauriejim
Copy link
Contributor

Hi @tranthebao what is the database you use ?

@tranthebao
Copy link
Author

yes, i'm using db mysql.

@lauriejim lauriejim added status: confirmed Confirmed by a Strapi Team member or multiple community members issue: feature request Issue suggesting a new feature and removed status: need more informations 🤔 issue: enhancement Issue suggesting an enhancement to an existing feature status: confirmed Confirmed by a Strapi Team member or multiple community members labels Mar 27, 2018
@lauriejim
Copy link
Contributor

lauriejim commented Mar 27, 2018

What you want is a validation layer in the router ?

Actually you will have to manually add it in your database structure.

@tranthebao
Copy link
Author

i'm see loopback when do method post then error server api return error.
you can reference to adrress loopback.io

@lauriejim lauriejim changed the title Can not validate model when rest api. Request params layer validation Apr 6, 2018
@lauriejim lauriejim assigned Aurelsicoko and unassigned lauriejim Apr 25, 2018
@Aurelsicoko
Copy link
Member

@tranthebao You've pointed out a great feature that we have to implement to make the framework better. There is already a feature request about the validation layer on the community vote page.

We're thinking about implementing Joi directly on the router like Hapi does. It works great and it's perfect to validate incoming and outcoming data. What do you think about that?

@nurikabe
Copy link
Contributor

I was just looking at https://github.com/koajs/joi-router. Looks very good for this.

@Aurelsicoko
Copy link
Member

I'm closing this issue because we'll implement it (see https://portal.productboard.com/strapi/c/14-validations). Feel free to give me more insights or upvote the card.

@igordelorenzi
Copy link

@nurikabe, apparently it has been tried in the past and it did not work (https://github.com/strapi/koa-router-joi). I'm wondering why?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment