pref: validation optimization of many edit form. (#223)

pull/230/head
弥枳 2020-08-08 10:10:21 +08:00 committed by GitHub
parent 3e872b551b
commit d72fe025c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 62 deletions

View File

@ -562,7 +562,7 @@ export default {
selectedComment: {}, selectedComment: {},
replyComment: {}, replyComment: {},
replyCommentRules: { replyCommentRules: {
content: [{ required: true, message: '* 内容不能为空', trigger: ['change', 'blur'] }] content: [{ required: true, message: '* 内容不能为空', trigger: ['change'] }]
}, },
loading: false, loading: false,
commentStatus: commentApi.commentStatus, commentStatus: commentApi.commentStatus,

View File

@ -279,15 +279,15 @@ export default {
errored: false, errored: false,
rules: { rules: {
name: [ name: [
{ required: true, message: '* 菜单名称不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 菜单名称不能为空', trigger: ['change'] },
{ max: 50, message: '* 菜单名称的字符长度不能超过 50', trigger: ['change', 'blur'] } { max: 50, message: '* 菜单名称的字符长度不能超过 50', trigger: ['change'] }
], ],
url: [ url: [
{ required: true, message: '* 菜单地址不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 菜单地址不能为空', trigger: ['change'] },
{ max: 1023, message: '* 菜单地址的字符长度不能超过 1023', trigger: ['change', 'blur'] } { max: 1023, message: '* 菜单地址的字符长度不能超过 1023', trigger: ['change'] }
], ],
icon: [{ max: 50, message: '* 菜单图标的字符长度不能超过 50', trigger: ['change', 'blur'] }], icon: [{ max: 50, message: '* 菜单图标的字符长度不能超过 50', trigger: ['change'] }],
team: [{ max: 255, message: '* 菜单分组的字符长度不能超过 255', trigger: ['change', 'blur'] }] team: [{ max: 255, message: '* 菜单分组的字符长度不能超过 255', trigger: ['change'] }]
}, },
moreField: false moreField: false
}, },

View File

@ -308,12 +308,12 @@ export default {
errored: false, errored: false,
rules: { rules: {
name: [ name: [
{ required: true, message: '* 分类名称不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 分类名称不能为空', trigger: ['change'] },
{ max: 255, message: '* 分类名称的字符长度不能超过 255', trigger: ['change', 'blur'] } { max: 255, message: '* 分类名称的字符长度不能超过 255', trigger: ['change'] }
], ],
slug: [{ max: 255, message: '* 分类别名的字符长度不能超过 255', trigger: ['change', 'blur'] }], slug: [{ max: 255, message: '* 分类别名的字符长度不能超过 255', trigger: ['change'] }],
thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change', 'blur'] }], thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change'] }],
description: [{ max: 100, message: '* 分类描述的字符长度不能超过 100', trigger: ['change', 'blur'] }] description: [{ max: 100, message: '* 分类描述的字符长度不能超过 100', trigger: ['change'] }]
} }
}, },
thumbnailDrawer: { thumbnailDrawer: {

View File

@ -150,11 +150,11 @@ export default {
errored: false, errored: false,
rules: { rules: {
name: [ name: [
{ required: true, message: '* 标签名称不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 标签名称不能为空', trigger: ['change'] },
{ max: 255, message: '* 标签名称的字符长度不能超过 255', trigger: ['change', 'blur'] } { max: 255, message: '* 标签名称的字符长度不能超过 255', trigger: ['change'] }
], ],
slug: [{ max: 255, message: '* 标签别名的字符长度不能超过 255', trigger: ['change', 'blur'] }], slug: [{ max: 255, message: '* 标签别名的字符长度不能超过 255', trigger: ['change'] }],
thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change', 'blur'] }] thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change'] }]
} }
}, },
thumbnailDrawer: { thumbnailDrawer: {

View File

@ -311,17 +311,17 @@ export default {
errored: false, errored: false,
rules: { rules: {
name: [ name: [
{ required: true, message: '* 友情链接名称不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 友情链接名称不能为空', trigger: ['change'] },
{ max: 255, message: '* 友情链接名称的字符长度不能超过 255', trigger: ['change', 'blur'] } { max: 255, message: '* 友情链接名称的字符长度不能超过 255', trigger: ['change'] }
], ],
url: [ url: [
{ required: true, message: '* 友情链接地址不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 友情链接地址不能为空', trigger: ['change'] },
{ max: 1023, message: '* 友情链接地址的字符长度不能超过 1023', trigger: ['change', 'blur'] }, { max: 1023, message: '* 友情链接地址的字符长度不能超过 1023', trigger: ['change'] },
{ type: 'url', message: '* 友情链接地址格式有误', trigger: ['change', 'blur'] } { type: 'url', message: '* 友情链接地址格式有误', trigger: ['change'] }
], ],
logo: [{ max: 1023, message: '* 友情链接 Logo 的字符长度不能超过 1023', trigger: ['change', 'blur'] }], logo: [{ max: 1023, message: '* 友情链接 Logo 的字符长度不能超过 1023', trigger: ['change'] }],
description: [{ max: 255, message: '* 友情链接描述的字符长度不能超过 255', trigger: ['change', 'blur'] }], description: [{ max: 255, message: '* 友情链接描述的字符长度不能超过 255', trigger: ['change'] }],
team: [{ max: 255, message: '* 友情链接分组的字符长度 255', trigger: ['change', 'blur'] }] team: [{ max: 255, message: '* 友情链接分组的字符长度 255', trigger: ['change'] }]
} }
}, },
optionsModal: { optionsModal: {

View File

@ -234,34 +234,34 @@ export default {
generalRules: { generalRules: {
username: [ username: [
{ required: true, message: '* 用户名不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 用户名不能为空', trigger: ['change'] },
{ max: 50, message: '* 用户名的字符长度不能超过 50', trigger: ['change', 'blur'] } { max: 50, message: '* 用户名的字符长度不能超过 50', trigger: ['change'] }
], ],
nickname: [ nickname: [
{ required: true, message: '* 用户昵称不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 用户昵称不能为空', trigger: ['change'] },
{ max: 255, message: '* 用户昵称的字符长度不能超过 255', trigger: ['change', 'blur'] } { max: 255, message: '* 用户昵称的字符长度不能超过 255', trigger: ['change'] }
], ],
email: [ email: [
{ required: true, message: '* 电子邮件地址不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 电子邮件地址不能为空', trigger: ['change'] },
{ max: 127, message: '* 电子邮件地址的字符长度不能超过 127', trigger: ['change', 'blur'] }, { max: 127, message: '* 电子邮件地址的字符长度不能超过 127', trigger: ['change'] },
{ {
pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/g, pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/g,
message: '* 电子邮件地址的格式不正确', message: '* 电子邮件地址的格式不正确',
trigger: ['change', 'blur'] trigger: ['change']
} }
], ],
password: [ password: [
{ required: true, message: '* 密码不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 密码不能为空', trigger: ['change'] },
{ min: 8, max: 100, message: '* 密码的字符长度必须在 8 - 100 之间', trigger: ['change', 'blur'] } { min: 8, max: 100, message: '* 密码的字符长度必须在 8 - 100 之间', trigger: ['change'] }
], ],
confirmPassword: [ confirmPassword: [
{ required: true, message: '* 确认密码不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 确认密码不能为空', trigger: ['change'] },
{ validator: confirmPasswordValidate, trigger: ['change', 'blur'] } { validator: confirmPasswordValidate, trigger: ['change'] }
] ]
}, },
blogRules: { blogRules: {
url: [{ required: true, message: '* 博客地址不能为空', trigger: ['change', 'blur'] }], url: [{ required: true, message: '* 博客地址不能为空', trigger: ['change'] }],
title: [{ required: true, message: '* 博客标题不能为空', trigger: ['change', 'blur'] }] title: [{ required: true, message: '* 博客标题不能为空', trigger: ['change'] }]
} }
} }
}, },

View File

@ -114,22 +114,22 @@ export default {
}, },
rules: { rules: {
blog_title: [ blog_title: [
{ required: true, message: '* 博客标题不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 博客标题不能为空', trigger: ['change'] },
{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change', 'blur'] } { max: 1023, message: '* 字符数不能超过 1023', trigger: ['change'] }
], ],
blog_url: [ blog_url: [
{ required: true, message: '* 博客地址不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 博客地址不能为空', trigger: ['change'] },
{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change', 'blur'] } { max: 1023, message: '* 字符数不能超过 1023', trigger: ['change'] }
], ],
blog_logo: [ blog_logo: [
{ type: 'url', message: '* 链接格式不正确', trigger: ['change', 'blur'] }, { type: 'url', message: '* 链接格式不正确', trigger: ['change'] },
{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change', 'blur'] } { max: 1023, message: '* 字符数不能超过 1023', trigger: ['change'] }
], ],
blog_favicon: [ blog_favicon: [
{ type: 'url', message: '* 链接格式不正确', trigger: ['change', 'blur'] }, { type: 'url', message: '* 链接格式不正确', trigger: ['change'] },
{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change', 'blur'] } { max: 1023, message: '* 字符数不能超过 1023', trigger: ['change'] }
], ],
blog_footer_info: [{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change', 'blur'] }] blog_footer_info: [{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change'] }]
} }
} }
}, },

View File

@ -73,8 +73,8 @@ export default {
xs: { span: 24 } xs: { span: 24 }
}, },
rules: { rules: {
seo_keywords: [{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change', 'blur'] }], seo_keywords: [{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change'] }],
seo_description: [{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change', 'blur'] }] seo_description: [{ max: 1023, message: '* 字符数不能超过 1023', trigger: ['change'] }]
} }
} }
}, },

View File

@ -387,19 +387,19 @@ export default {
errored: false, errored: false,
rules: { rules: {
username: [ username: [
{ required: true, message: '* 用户名不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 用户名不能为空', trigger: ['change'] },
{ max: 50, message: '* 用户名的字符长度不能超过 50', trigger: ['change', 'blur'] } { max: 50, message: '* 用户名的字符长度不能超过 50', trigger: ['change'] }
], ],
nickname: [ nickname: [
{ required: true, message: '* 用户昵称不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 用户昵称不能为空', trigger: ['change'] },
{ max: 255, message: '* 用户昵称的字符长度不能超过 255', trigger: ['change', 'blur'] } { max: 255, message: '* 用户昵称的字符长度不能超过 255', trigger: ['change'] }
], ],
email: [ email: [
{ required: true, message: '* 电子邮箱地址不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 电子邮箱地址不能为空', trigger: ['change'] },
{ type: 'email', message: '* 电子邮箱地址格式不正确', trigger: ['change', 'blur'] }, { type: 'email', message: '* 电子邮箱地址格式不正确', trigger: ['change'] },
{ max: 127, message: '* 电子邮箱的字符长度不能超过 255', trigger: ['change', 'blur'] } { max: 127, message: '* 电子邮箱的字符长度不能超过 255', trigger: ['change'] }
], ],
description: [{ max: 1023, message: '* 个人说明的字符长度不能超过 1023', trigger: ['change', 'blur'] }] description: [{ max: 1023, message: '* 个人说明的字符长度不能超过 1023', trigger: ['change'] }]
} }
}, },
statistics: { statistics: {
@ -416,16 +416,16 @@ export default {
errored: false, errored: false,
rules: { rules: {
oldPassword: [ oldPassword: [
{ required: true, message: '* 原密码不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 原密码不能为空', trigger: ['change'] },
{ max: 100, min: 8, message: '* 密码的字符长度必须在 8 - 100 之间', trigger: ['blur'] } { max: 100, min: 8, message: '* 密码的字符长度必须在 8 - 100 之间', trigger: ['blur'] }
], ],
newPassword: [ newPassword: [
{ required: true, message: '* 新密码不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 新密码不能为空', trigger: ['change'] },
{ max: 100, min: 8, message: '* 密码的字符长度必须在 8 - 100 之间', trigger: ['change', 'blur'] } { max: 100, min: 8, message: '* 密码的字符长度必须在 8 - 100 之间', trigger: ['change'] }
], ],
confirmPassword: [ confirmPassword: [
{ required: true, message: '* 确认密码不能为空', trigger: ['change', 'blur'] }, { required: true, message: '* 确认密码不能为空', trigger: ['change'] },
{ validator: validateConfirmPassword, trigger: ['change', 'blur'] } { validator: validateConfirmPassword, trigger: ['change'] }
] ]
} }
}, },
@ -444,7 +444,7 @@ export default {
checked: false checked: false
}, },
rules: { rules: {
authcode: [{ required: true, message: '* 两步验证码不能为空', trigger: ['change', 'blur'] }] authcode: [{ required: true, message: '* 两步验证码不能为空', trigger: ['change'] }]
}, },
saving: false, saving: false,
errored: false errored: false