element-plus/packages/utils/validators.ts
Enoch Qin 79876b9733
refactor(date-picker): attribute 'type' add ts declare (#1979)
* refactor(date-picker): attribute 'type' add ts declare

* refactor(date-picker): add isValidDatePicktype utils

* style: date-picker code fix

* Update date-picker.ts

Co-authored-by: jeremywu <15975785+JeremyWuuuuu@users.noreply.github.com>
2021-05-21 15:30:12 +08:00

28 lines
592 B
TypeScript

import { isNumber } from './util'
export const isValidWidthUnit = (val: string | number): boolean =>{
if(isNumber(val)){
return true
} else {
return ['px', 'rem', 'em', 'vw', '%', 'vmin', 'vmax'].some(unit =>
(val as string).endsWith(unit),
)
}
}
export const isValidComponentSize = (val: string) =>
['', 'large', 'medium', 'small', 'mini'].includes(val)
export const isValidDatePickType = (val: string) =>
[
'year',
'month',
'date',
'dates',
'week',
'datetime',
'datetimerange',
'daterange',
'monthrange',
].includes(val)