element-plus/packages/utils/validators.ts

17 lines
417 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),
)
}
return false
}
2020-10-30 23:26:33 +08:00
export const isValidComponentSize = (val: string) =>
['', 'large', 'medium', 'small', 'mini'].includes(val)