Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: global inject for veui-loader, i18n for rules
- Loading branch information
Showing
17 changed files
with
140 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './rules' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import './common' | ||
import './Alert' | ||
import './Calendar' | ||
import './Carousel' | ||
import './DatePicker' | ||
import './Dialog' | ||
import './FilterPanel' | ||
import './Input' | ||
import './NumberInput' | ||
import './Pagination' | ||
import './Progress' | ||
import './RegionPicker' | ||
import './Schedule' | ||
import './Searchbox' | ||
import './Select' | ||
import './Steps' | ||
import './Table' | ||
import './Tabs' | ||
import './Transfer' | ||
import './Uploader' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import i18n from '../../managers/i18n' | ||
|
||
i18n.register( | ||
'en-US', | ||
{ | ||
max: 'Can\'t be greater than {ruleValue}', | ||
maxLength: 'Can\'t be more than {ruleValue} characters', | ||
min: 'Can\'t be less than {ruleValue}', | ||
minLength: 'Can\'t be less than {ruleValue} characters', | ||
numeric: 'The value must be a number', | ||
pattern: 'Invalid pattern', | ||
required: 'Required' | ||
}, | ||
{ | ||
ns: 'rules' | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './rules' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import './common' | ||
import './Alert' | ||
import './Calendar' | ||
import './Carousel' | ||
import './DatePicker' | ||
import './Dialog' | ||
import './FilterPanel' | ||
import './Input' | ||
import './NumberInput' | ||
import './Pagination' | ||
import './Progress' | ||
import './RegionPicker' | ||
import './Schedule' | ||
import './Searchbox' | ||
import './Select' | ||
import './Steps' | ||
import './Table' | ||
import './Tabs' | ||
import './Transfer' | ||
import './Uploader' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import i18n from '../../managers/i18n' | ||
|
||
i18n.register( | ||
'zh-Hans', | ||
{ | ||
max: '不能大于{ruleValue}', | ||
maxLength: '字符长度不能超过{ruleValue}', | ||
min: '不能小于{ruleValue}', | ||
minLength: '字符长度不能短于{ruleValue}', | ||
numeric: '值必须为数字', | ||
pattern: '格式不符合要求', | ||
required: '请填写' | ||
}, | ||
{ | ||
ns: 'rules' | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { isEmpty } from '../../utils/helper' | ||
import { isNumber } from 'lodash' | ||
import { isEmpty } from '../../utils/helper' | ||
import i18n from '../i18n' | ||
|
||
export default { | ||
validate (val, ruleValue) { | ||
return !isEmpty(val) && isNumber(val) ? val <= ruleValue : true | ||
}, | ||
message: '不能大于${ruleValue}', | ||
message (value, ruleValue) { | ||
return i18n.get('rules.max', { value, ruleValue }) | ||
}, | ||
priority: 200 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import { isEmpty } from '../../utils/helper' | ||
import i18n from '../i18n' | ||
|
||
export default { | ||
validate (val, ruleValue) { | ||
return !isEmpty(val) ? val.length <= ruleValue : true | ||
}, | ||
message: '字符长度不能超过${ruleValue}', | ||
message (value, ruleValue) { | ||
return i18n.get('rules.maxLength', { value, ruleValue }) | ||
}, | ||
priority: 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { isEmpty } from '../../utils/helper' | ||
import { isNumber } from 'lodash' | ||
import { isEmpty } from '../../utils/helper' | ||
import i18n from '../i18n' | ||
|
||
export default { | ||
validate (val, ruleValue) { | ||
return !isEmpty(val) && isNumber(val) ? val >= ruleValue : true | ||
}, | ||
message: '不能小于${ruleValue}', | ||
message (value, ruleValue) { | ||
return i18n.get('rules.min', { value, ruleValue }) | ||
}, | ||
priority: 200 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import { isEmpty } from '../../utils/helper' | ||
import i18n from '../i18n' | ||
|
||
export default { | ||
validate (val, ruleValue) { | ||
return !isEmpty(val) ? val.length >= ruleValue : true | ||
}, | ||
message: '字符长度不能短于${ruleValue}', | ||
message (value, ruleValue) { | ||
return i18n.get('rules.minLength', { value, ruleValue }) | ||
}, | ||
priority: 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { isNumber, toNumber, isNaN, isString } from 'lodash' | ||
import { isEmpty } from '../../utils/helper' | ||
import i18n from '../i18n' | ||
|
||
export default { | ||
validate (val) { | ||
return !isEmpty(val) | ||
? isNumber(val) || isString(val) && !/^0(?!\.|e)/.test(val) && !isNaN(toNumber(val)) | ||
: true | ||
}, | ||
message: '值必须为数字', | ||
message (value, ruleValue) { | ||
return i18n.get('rules.numeric', { value, ruleValue }) | ||
}, | ||
priority: 10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { isType, getTypeByInstance } from '../../utils/lang' | ||
import i18n from '../i18n' | ||
|
||
export default { | ||
validate (val, ruleValue) { | ||
return isType(getTypeByInstance(ruleValue), RegExp) | ||
? ruleValue.test(val) | ||
: new RegExp(ruleValue).test(val) | ||
}, | ||
message: '格式不符合要求', | ||
message (value, ruleValue) { | ||
return i18n.get('rules.pattern', { value, ruleValue }) | ||
}, | ||
priority: 50 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import { isEmpty } from '../../utils/helper' | ||
import i18n from '../i18n' | ||
|
||
export default { | ||
validate (val) { | ||
return !isEmpty(val) | ||
}, | ||
message: '请填写', | ||
message (value, ruleValue) { | ||
return i18n.get('rules.required', { value, ruleValue }) | ||
}, | ||
priority: 0 | ||
} |