Skip to content

Commit

Permalink
chore(validator): improve validator (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Jul 31, 2021
1 parent 9850f76 commit b1681bf
Show file tree
Hide file tree
Showing 31 changed files with 251 additions and 70 deletions.
9 changes: 9 additions & 0 deletions .umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ export default {
background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png);
background-size: cover;
background-repeat: no-repeat;
padding: 120px 0 !important;
}
.__dumi-default-layout-hero h1{
color:#45124e !important;
font-size:80px !important;
padding-bottom: 30px !important;
}
.__dumi-default-dark-switch {
display:none
}
nav a{
text-decoration: none !important;
Expand Down
17 changes: 9 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ title: Formily - Alibaba unified front-end form solution
order: 10
hero:
title: Alibaba Formily
desc: Alibaba unified front-end form solution
desc: Alibaba Unified Front-end Form Solution
actions:
- text: Quick start
- text: Introduction
link: /guide
- text: Quick start
link: /guide/quick-start
features:
- icon: https://img.alicdn.com/imgextra/i2/O1CN016i72sH1c5wh1kyy9U_!!6000000003550-55-tps-800-800.svg
title: Easier to Use
Expand Down Expand Up @@ -56,12 +58,11 @@ export default () => (
<Section
title="Form Builder,Efficient Development"
style={{ marginTop: 140, fontWeight: 'bold' }}
titleStyle={{ paddingBottom: 140 }}
scale={1.2}
>
<a href="//designable-antd.formilyjs.org" target="_blank" rel="noreferrer">
<img
style={{ transform: 'scale(1.2)', boxShadow: 'none' }}
src="//img.alicdn.com/imgextra/i2/O1CN01eI9FLz22tZek2jv7E_!!6000000007178-2-tps-3683-2272.png"
/>
<img src="//img.alicdn.com/imgextra/i2/O1CN01eI9FLz22tZek2jv7E_!!6000000007178-2-tps-3683-2272.png" />
</a>
</Section>
)
Expand Down Expand Up @@ -99,7 +100,7 @@ import './site/styles.less'
export default () => (
<Section
title="Active Community & Genius People"
style={{ marginTop: 140 }}
style={{ marginTop: 100 }}
titleStyle={{ paddingBottom: 140, fontWeight: 'bold' }}
>
<a href="https://github.com/alibaba/formily/graphs/contributors">
Expand All @@ -120,7 +121,7 @@ import './site/styles.less'

export default () => (
<Section
title="High-quality Community group"
title="High-Quality Community Group"
style={{ marginTop: 140 }}
titleStyle={{ paddingBottom: 140, fontWeight: 'bold' }}
>
Expand Down
18 changes: 11 additions & 7 deletions docs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ hero:
title: Alibaba Formily
desc: 阿里巴巴统一前端表单解决方案
actions:
- text: 快速开始
- text: 查看文档
link: /zh-CN/guide
- text: 快速开始
link: /zh-CN/guide/quick-start
features:
- icon: https://img.alicdn.com/imgextra/i2/O1CN016i72sH1c5wh1kyy9U_!!6000000003550-55-tps-800-800.svg
title: 更易用
Expand Down Expand Up @@ -53,12 +55,14 @@ import { Section } from './site/Section'
import './site/styles.less'

export default () => (
<Section title="拖拽搭建,高效开发" style={{ marginTop: 140 }}>
<Section
title="拖拽搭建,高效开发"
style={{ marginTop: 140 }}
titleStyle={{ paddingBottom: 140 }}
scale={1.2}
>
<a href="//designable-antd.formilyjs.org" target="_blank" rel="noreferrer">
<img
style={{ transform: 'scale(1.2)', boxShadow: 'none' }}
src="//img.alicdn.com/imgextra/i2/O1CN01eI9FLz22tZek2jv7E_!!6000000007178-2-tps-3683-2272.png"
/>
<img src="//img.alicdn.com/imgextra/i2/O1CN01eI9FLz22tZek2jv7E_!!6000000007178-2-tps-3683-2272.png" />
</a>
</Section>
)
Expand Down Expand Up @@ -96,7 +100,7 @@ import './site/styles.less'
export default () => (
<Section
title="社区活跃,能者众多"
style={{ marginTop: 140 }}
style={{ marginTop: 100 }}
titleStyle={{ paddingBottom: 140 }}
>
<a href="https://github.com/alibaba/formily/graphs/contributors">
Expand Down
5 changes: 2 additions & 3 deletions docs/site/Section.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
text-align: center;
padding-bottom: 200px;
position: relative;
color: #45124e;

@media (max-width: 480px) {

font-size: 30px;

}
}
}
}
8 changes: 7 additions & 1 deletion docs/site/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ISectionProps {
title?: React.ReactNode
style?: React.CSSProperties
titleStyle?: React.CSSProperties
scale?: number
}

export const Section: React.FC<ISectionProps> = (props) => {
Expand All @@ -13,7 +14,12 @@ export const Section: React.FC<ISectionProps> = (props) => {
<div className="site-section-title" style={props.titleStyle}>
{props.title}
</div>
<div className="site-section-body">{props.children}</div>
<div
className="site-section-body"
style={{ transform: `scale(${props.scale || 1})` }}
>
{props.children}
</div>
</section>
)
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"start": "dumi dev",
"test": "jest --coverage",
"test:reactive": "jest packages/reactive",
"test:validator": "jest packages/validator",
"test:core": "jest packages/core",
"test:core:watch": "npm run test:core --- --watch",
"test:schema": "jest packages/json-schema",
Expand Down
9 changes: 9 additions & 0 deletions packages/antd/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ export default {
background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png);
background-size: cover;
background-repeat: no-repeat;
padding: 120px 0 !important;
}
.__dumi-default-layout-hero h1{
color:#45124e !important;
font-size:80px !important;
padding-bottom: 30px !important;
}
.__dumi-default-dark-switch {
display:none
}
nav a{
text-decoration: none !important;
Expand Down
4 changes: 2 additions & 2 deletions packages/antd/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: Formily-Alibaba unified front-end form solution
order: 10
hero:
title: FORMILY ANTD
desc: An elegant and easy-to-use Formily 2.x component system based on Ant Design encapsulation
title: Formily Antd
desc: Formily Component System Based on Ant Design Encapsulation
actions:
- text: Home Site
link: //v2.formilyjs.org
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/docs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Formily - 阿里巴巴统一前端表单解决方案
order: 10
hero:
title: FORMILY ANTD
title: Formily Antd
desc: 基于Ant Design封装的优雅且易用的Formily2.x组件体系
actions:
- text: 主站文档
Expand Down
9 changes: 9 additions & 0 deletions packages/core/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export default {
background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png);
background-size: cover;
background-repeat: no-repeat;
padding: 120px 0 !important;
}
.__dumi-default-layout-hero h1{
color:#45124e !important;
font-size:80px !important;
padding-bottom: 30px !important;
}
.__dumi-default-dark-switch {
display:none
}
nav a{
text-decoration: none !important;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: Formily-Alibaba unified front-end form solution
order: 10
hero:
title: FORMILY CORE
desc: Alibaba unified front-end form solution
title: Core Library
desc: Alibaba Unified Form Solution
actions:
- text: Home Site
link: //v2.formilyjs.org
Expand Down
2 changes: 1 addition & 1 deletion packages/core/docs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Formily - 阿里巴巴统一前端表单解决方案
order: 10
hero:
title: FORMILY CORE
title: Core Library
desc: 阿里巴巴统一前端表单解决方案
actions:
- text: 主站文档
Expand Down
17 changes: 17 additions & 0 deletions packages/core/src/__tests__/form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1150,3 +1150,20 @@ test('setValues deep merge', () => {
},
})
})

test('exception validate', async () => {
const form = attach(createForm())
attach(
form.createField({
name: 'aa',
validator() {
throw new Error('runtime error')
},
})
)
try {
await form.validate()
} catch {}
expect(form.invalid).toBeTruthy()
expect(form.validating).toBeFalsy()
})
2 changes: 1 addition & 1 deletion packages/element/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
home: true
heroText: FORMILY ELEMENT
heroText: Formily Element
tagline: 基于 Element UI 封装的Formily2.x组件体系
actionText: 开发指南
actionLink: /guide/
Expand Down
9 changes: 9 additions & 0 deletions packages/next/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ export default {
background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png);
background-size: cover;
background-repeat: no-repeat;
padding: 120px 0 !important;
}
.__dumi-default-layout-hero h1{
color:#45124e !important;
font-size:80px !important;
padding-bottom: 30px !important;
}
.__dumi-default-dark-switch {
display:none
}
nav a{
text-decoration: none !important;
Expand Down
4 changes: 2 additions & 2 deletions packages/next/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: Formily-Alibaba unified front-end form solution
order: 10
hero:
title: FORMILY NEXT
desc: Elegant and easy-to-use Formily 2.x component system based on Alibaba Fusion package
title: Formily Fusion
desc: Formily Component System Based on Alibaba Fusion Encapsulation
actions:
- text: Home Site
link: //v2.formilyjs.org
Expand Down
2 changes: 1 addition & 1 deletion packages/next/docs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Formily - 阿里巴巴统一前端表单解决方案
order: 10
hero:
title: FORMILY NEXT
title: Formily Fusion
desc: 基于Alibaba Fusion封装的优雅且易用的Formily2.x组件体系
actions:
- text: 主站文档
Expand Down
9 changes: 9 additions & 0 deletions packages/react/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ export default {
background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png);
background-size: cover;
background-repeat: no-repeat;
padding: 120px 0 !important;
}
.__dumi-default-layout-hero h1{
color:#45124e !important;
font-size:80px !important;
padding-bottom: 30px !important;
}
.__dumi-default-dark-switch {
display:none
}
nav a{
text-decoration: none !important;
Expand Down
4 changes: 2 additions & 2 deletions packages/react/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: Formily-Alibaba unified front-end form solution
order: 10
hero:
title: FORMILY REACT
desc: Alibaba unified front-end form solution
title: React Library
desc: Alibaba Unified Form Solution
actions:
- text: Home Site
link: //v2.formilyjs.org
Expand Down
2 changes: 1 addition & 1 deletion packages/react/docs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Formily - 阿里巴巴统一前端表单解决方案
order: 10
hero:
title: FORMILY REACT
title: React Library
desc: 阿里巴巴统一前端表单解决方案
actions:
- text: 主站文档
Expand Down
8 changes: 8 additions & 0 deletions packages/reactive/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ export default {
background-size: cover;
background-repeat: no-repeat;
}
.__dumi-default-layout-hero h1{
color:#45124e !important;
font-size:80px !important;
padding-bottom: 10px !important;
}
.__dumi-default-dark-switch {
display:none
}
nav a{
text-decoration: none !important;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/reactive/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: Formily-Alibaba unified front-end form solution
order: 10
hero:
title: FORMILY REACTIVE
desc: DDD-oriented responsive state management solution
title: Reactive Library
desc: DDD-oriented Responsive State Management Solution
actions:
- text: Home Site
link: //v2.formilyjs.org
Expand Down
2 changes: 1 addition & 1 deletion packages/reactive/docs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Formily - 阿里巴巴统一前端表单解决方案
order: 10
hero:
title: FORMILY REACTIVE
title: Reactive Library
desc: 面向DDD的响应式状态管理方案
actions:
- text: 主站文档
Expand Down
27 changes: 27 additions & 0 deletions packages/validator/src/__tests__/parser.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { parseValidatorDescriptions } from '../parser'

describe('parseValidatorDescriptions', () => {
test('basic', () => {
expect(parseValidatorDescriptions('date')).toEqual([
{ format: 'date', triggerType: 'onInput' },
])
const validator = () => {
return ''
}
expect(parseValidatorDescriptions(validator)).toEqual([
{ validator, triggerType: 'onInput' },
])
expect(parseValidatorDescriptions(['date'])).toEqual([
{ format: 'date', triggerType: 'onInput' },
])
expect(parseValidatorDescriptions([validator])).toEqual([
{ validator, triggerType: 'onInput' },
])
expect(parseValidatorDescriptions({ format: 'date' })).toEqual([
{ format: 'date', triggerType: 'onInput' },
])
expect(parseValidatorDescriptions({ validator })).toEqual([
{ validator, triggerType: 'onInput' },
])
})
})
10 changes: 10 additions & 0 deletions packages/validator/src/__tests__/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { getValidateLocaleIOSCode } from '../'

test('getValidateLocaleIOSCode', () => {
expect(getValidateLocaleIOSCode('zh-CN')).toEqual('zh-CN')
expect(getValidateLocaleIOSCode('zh')).toEqual('zh')
expect(getValidateLocaleIOSCode('ZH')).toEqual('zh')
expect(getValidateLocaleIOSCode('cn')).toEqual('zh-CN')
expect(getValidateLocaleIOSCode('en')).toEqual('en')
expect(getValidateLocaleIOSCode('TW')).toEqual('zh-TW')
})
Loading

0 comments on commit b1681bf

Please sign in to comment.