element-plus/packages/utils/validators.ts

16 lines
402 B
TypeScript
Raw Normal View History

import { isNumber } from '@element-plus/utils/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),
)
}
}
2020-10-30 23:26:33 +08:00
export const isValidComponentSize = (val: string) =>
['', 'large', 'medium', 'small', 'mini'].includes(val)