mealie/frontend/composables/use-validators.ts
hay-kot 91f56b42de refactor(frontend): 🏗️ scafold pages and componenets folder
Setup the file structure for components, pages, layouts, api, and all new frontend structure
2021-07-31 14:45:28 -08:00

8 lines
426 B
TypeScript

const EMAIL_REGEX =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
export const validators = {
required: (v: string) => !!v || "This Field is Required",
email: (v: string) => !v || EMAIL_REGEX.test(v) || "Email Must Be Valid",
whitespace: (v: string) => !v || v.split(" ").length <= 1 || "No Whitespace Allowed"
}