element-plus/packages/utils/validators.ts
三咲智子 55348b30b6
style: use prettier (#3228)
* style: use prettier

* style: just prettier format, no code changes

* style: eslint fix
object-shorthand, prefer-const

* style: fix no-void

* style: no-console
2021-09-04 19:29:28 +08:00

30 lines
652 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)
) || (val as string).startsWith('calc')
)
}
}
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)