@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
18 lines (14 loc) • 562 B
text/typescript
import { ValidationRule } from '@prefecthq/vue-compositions'
import { isEmptyArray, isEmptyString, isInvalidDate, isNullish } from '@/utilities'
export const isRequired: ValidationRule<unknown> = (value, name) => {
if (isNullish(value) || isEmptyArray(value) || isEmptyString(value) || isInvalidDate(value)) {
return `${name} is required`
}
return true
}
export const isGreaterThanZeroOrNull: ValidationRule<number | undefined> = (value, name) => {
if (value == null || value > 0) {
return true
}
return `${name} must be greater than 0`
}