Files
speckle-server/packages/frontend-2/lib/common/helpers/validation.ts
T
Kristaps Fabians Geikins 83d8035dc2 chore: upgrade to eslint 9 (#2348)
* root + server

* frontend

* frontend-2

* dui3

* dui3

* tailwind theme

* ui-components

* preview service

* viewer

* viewer-sandbox

* fileimport-service

* webhook service

* objectloader

* shared

* ui-components-nuxt

* WIP full config

* WIP full linter

* eslint projectwide util

* minor fix

* removing redundant ci

* clean up test errors

* fixed prettier formatting

* CI improvements

* TSC lint fix

* 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader

* removed unnecessary void

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
2024-06-12 14:38:02 +03:00

42 lines
1.4 KiB
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
import { ValidationHelpers } from '@speckle/ui-components'
import type { useForm } from 'vee-validate'
export const VALID_HTTP_URL = ValidationHelpers.VALID_HTTP_URL
export const VALID_EMAIL = ValidationHelpers.VALID_EMAIL
/**
* Note about new validators:
* Make sure you use the word "Value" to refer to the value being validated in all error messages, cause the dynamic string replace
* that replaces that part with the actual field name works based on that
*/
/**
* E-mail validation rule (not perfect, but e-mails should be validated by sending out confirmation e-mails anyway)
*/
export const isEmail = ValidationHelpers.isEmail
export const isOneOrMultipleEmails = ValidationHelpers.isOneOrMultipleEmails
export const isRequired = ValidationHelpers.isRequired
export const isSameAs = ValidationHelpers.isSameAs
export const isStringOfLength = ValidationHelpers.isStringOfLength
export const stringContains = ValidationHelpers.stringContains
export const isUrl = ValidationHelpers.isUrl
export const isItemSelected = ValidationHelpers.isItemSelected
/**
* Wrapper over useForm's `resetForm` that fully resets the form and its initial values
* @param veeValidateResetForm The `resetForm` function returned by vee-validate's `useForm`
*/
export function fullyResetForm(
veeValidateResetForm: ReturnType<typeof useForm<any>>['resetForm']
) {
veeValidateResetForm({ values: {} })
}