Move software files one directory up, Readme

This commit is contained in:
2024-11-19 16:51:28 +01:00
parent 9fa2b753ec
commit b347df7c6e
329 changed files with 255 additions and 31 deletions

View File

@@ -0,0 +1,171 @@
import { useFeedbackStore } from "@/stores/feedback.store"
/**
* Check a string for no numbers and more than four digits
*
* @param [minChars=4] Minimal number of characters
*
* @returns Array of rules
*/
export function getStringRules(minChars = 4) {
const feedbackStore = useFeedbackStore()
return [
value => {
if (value) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.required')
}
},
value => {
if (/[^0-9]/.test(value)) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.noDigitsAllowed')
}
},
value => {
if (value?.length >= minChars) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.notEnoughChars')
}
}
]
}
/**
* Check a string for exact five digits length and only digits
*
* @returns Array of rules
*/
export function getPostalRules() {
const feedbackStore = useFeedbackStore()
return [
value => {
if (value?.length == 5) {
return true
} else if (value?.length < 5) {
return feedbackStore.i18n.t('misc.validation.notEnoughChars')
} else {
return feedbackStore.i18n.t('misc.validation.tooMuchChars')
}
},
value => {
if (value?.length == 5) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.notEnoughChars')
}
},
value => {
if (/^\d+$/.test(value)) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.onlyDigitsAllowed')
}
}
]
}
/**
* Check a string for not empty and first char is a digit
*
* @returns Array of rules
*/
export function getNumberStartRules() {
const feedbackStore = useFeedbackStore()
return [
value => {
if (value) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.required')
}
},
value => {
if (/^\d/.test(value)) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.digitsAtStartNeeded')
}
},
]
}
/**
* Check a string for email format
*
* @returns Array of rules
*/
export function getEmailRules() {
const feedbackStore = useFeedbackStore()
return [
value => {
if (value) return true
return feedbackStore.i18n.t('account.emailRequired')
},
value => {
if (/.+@.+\..+/.test(value)) return true
return feedbackStore.i18n.t('account.emailIsNotValid')
},
]
}
/**
* Check a string for a good password
*
* @returns Array of rules
*/
export function getPasswordRules() {
const feedbackStore = useFeedbackStore()
return [
value => {
if (value) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.required')
}
},
value => {
if (value?.length >= 8) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.notEnoughChars')
}
}
]
}
/**
* Check a string for IBAN format
*
* @returns Array of rules
*/
export function getIbanRules() {
const feedbackStore = useFeedbackStore()
return [
value => {
if (value) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.required')
}
},
value => {
if (/[A-Z]{2}[0-9]{2}(?:[ ]?[0-9]{4}){4}(?!(?:[ ]?[0-9]){3})(?:[ ]?[0-9]{1,2})?/.test(value)) {
return true
} else {
return feedbackStore.i18n.t('account.wrongIban')
}
}
]
}