element-plus/packages/utils/validators.ts
2021-04-09 13:45:21 +08:00

16 lines
384 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)