2019-04-30 11:11:25 +08:00
|
|
|
export default {
|
2019-11-07 10:41:14 +08:00
|
|
|
title: '表单验证示例',
|
|
|
|
toolbar: "<a target='_blank' href='/docs/renderers/Form/FormItem'>文档</a>",
|
|
|
|
body: [
|
|
|
|
{
|
|
|
|
type: 'form',
|
|
|
|
autoFocus: false,
|
|
|
|
messages: {
|
|
|
|
validateFailed: '请仔细检查表单规则,部分表单项没通过验证'
|
|
|
|
},
|
|
|
|
title: '表单',
|
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
type: 'submit',
|
|
|
|
label: '提交'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
api: '/api/mock2/form/saveFormFailed?waitSeconds=2',
|
|
|
|
mode: 'horizontal',
|
2021-06-07 10:09:55 +08:00
|
|
|
body: [
|
2019-11-07 10:41:14 +08:00
|
|
|
{
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
name: 'test',
|
|
|
|
label: '必填',
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'test1',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-email',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: 'Email'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'url',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-url',
|
2020-08-06 12:24:31 +08:00
|
|
|
label: 'URL'
|
2019-11-07 10:41:14 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'num',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: '数字',
|
|
|
|
validations: 'isNumeric'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'alpha',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: '字母或数字',
|
|
|
|
validations: 'isAlphanumeric'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'int',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: '整形',
|
|
|
|
validations: 'isInt'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'minLength',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: '长度限制',
|
|
|
|
validations: 'minLength:2,maxLength:10'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'min',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: '数值限制',
|
|
|
|
validations: 'maximum:10,minimum:2'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'reg',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: '正则',
|
|
|
|
validations: 'matchRegexp:/^abc/',
|
|
|
|
validationErrors: {
|
|
|
|
matchRegexp: '请输入abc开头的好么?'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'test2',
|
2021-06-07 10:09:55 +08:00
|
|
|
type: 'input-text',
|
2019-11-07 10:41:14 +08:00
|
|
|
label: '服务端验证'
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
2019-11-07 10:41:14 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2019-04-30 11:11:25 +08:00
|
|
|
};
|