服务器端字段目前没有校验功能
#2568
Replies: 4 comments
-
NocoBase 的默认设定,对字段并不做后端校验,暂时所有的校验只是前端有效。如果有服务端校验需要可以参考这里的配置: 完整的校验模块会独立出来考虑,有计划,但是优先级不高。 |
Beta Was this translation helpful? Give feedback.
0 replies
-
使用 sequelize 的 validation 是可以的,比如这样是生效的: app.collection({
name: "posts",
createdBy: true,
fields: [
{ type: "string", name: "title" },
{ type: "text", name: "content" },
{ type: "string", name: "email", validate: { isEmail: true } },
],
}); 通过 response = await request(app.callback())
.post("/api/collections")
.set("Authorization", `Bearer ${user.token}`)
.send({
name: "posts",
fields: [
{
name: "title",
type: "string",
},
{
name: "email",
type: "string",
validate: { isEmail: true },
},
],
});
expect(response.statusCode).toEqual(200);
response = await request(app.callback())
.post(`/api/posts`)
.set("Authorization", `Bearer ${user.token}`)
.send({
title: "hello",
email: "a@b.com",
});
expect(response.statusCode).toEqual(200);
response = await request(app.callback())
.post(`/api/posts`)
.set("Authorization", `Bearer ${user.token}`)
.send({
title: "hi",
email: "b",
});
expect(response.statusCode).toEqual(400); 完整的校验模块没出来之前,考虑编写脚本,更新 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Google Translation to English: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
使用版本分支是:nocobase_next
通过界面创建了一个名为
customers
的 collection:有一个名为
email
的字段,需要做邮件格式校验,在界面添加是有校验的,但如果用 api 形式调用发现服务器端目前还没有做校验。是否有加入服务器端校验功能的计划?
Beta Was this translation helpful? Give feedback.
All reactions