export const getLocalToken = () => localStorage.getItem("token"); export const saveLocalToken = (token: string) => localStorage.setItem("token", token); export const removeLocalToken = () => localStorage.removeItem("token"); import type { Ref } from "vue"; import { useI18n } from "vue-i18n"; // export const emailRules = [ // (v:any) => /^[a-z.0-9]+@[a-z.-]+\.[a-z]+$/i.test(v) || 'Must be a valid e-mail.', // ]; // export const required = [ // (v:any) => !!v || ('This field is required.'), // ]; export function emailRules() { const { t } = useI18n(); return [(v:any) => /^[a-z.0-9]+@[a-z.-]+\.[a-z]+$/i.test(v) || t('emailRules')]; } export function required() { const { t } = useI18n(); return [(v: any) => !!v || t('required')]; } export const nameRules = [ (v:any) => !!v || 'Name is required.', ]; export const password1Rules = [ (v:any) => !!v || 'Password is required.', (v:any) => (v && v.length >= 8) || 'Password must be more than 8 characters', ]; export const usePassword2Rules = (password1:Ref) => [ (password2:string) => (password2 === password1.value) || 'Input same password.', ]