bt-core-app 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +3 -0
- package/README.md +45 -0
- package/index.html +13 -0
- package/package.json +39 -0
- package/public/vite.svg +1 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/BT-Btn.vue +40 -0
- package/src/components/BT-Col.vue +36 -0
- package/src/components/BT-Span.vue +21 -0
- package/src/components/Dialog-Confirm.vue +47 -0
- package/src/components/Dialog-Select-Date.vue +89 -0
- package/src/components/Dialog-Select.vue +140 -0
- package/src/components/Dialog-Text.vue +59 -0
- package/src/composables/actions-tracker.ts +99 -0
- package/src/composables/actions.ts +354 -0
- package/src/composables/api.ts +471 -0
- package/src/composables/auth.ts +382 -0
- package/src/composables/cosmetics.ts +178 -0
- package/src/composables/csv.ts +198 -0
- package/src/composables/dates.ts +79 -0
- package/src/composables/demo.ts +25 -0
- package/src/composables/dialogs.ts +115 -0
- package/src/composables/document-meta.ts +40 -0
- package/src/composables/draggable.ts +189 -0
- package/src/composables/filters.ts +256 -0
- package/src/composables/forage.ts +49 -0
- package/src/composables/helpers.ts +694 -0
- package/src/composables/id.ts +20 -0
- package/src/composables/list.ts +601 -0
- package/src/composables/navigation.ts +214 -0
- package/src/composables/presets.ts +20 -0
- package/src/composables/pwa.ts +89 -0
- package/src/composables/resizable.ts +382 -0
- package/src/composables/rules.ts +40 -0
- package/src/composables/stores.ts +797 -0
- package/src/composables/track.ts +55 -0
- package/src/composables/urls.ts +11 -0
- package/src/core.ts +92 -0
- package/src/index.ts +16 -0
- package/src/types.ts +13 -0
- package/src/useApi.ts +68 -0
- package/src/vite-env.d.ts +1 -0
- package/test/api.test.ts +84 -0
- package/test/forage.test.ts +31 -0
- package/test/helpers.test.ts +231 -0
- package/test/navigation.test.ts +99 -0
- package/test/stores-last-update.test.ts +138 -0
- package/test/stores-session.test.ts +118 -0
- package/test/track.test.ts +29 -0
- package/test/utils.ts +15 -0
- package/tsconfig.json +33 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +19 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { validEmail } from '@/composables/helpers'
|
|
2
|
+
|
|
3
|
+
interface UseRulesOptions {
|
|
4
|
+
forEmail?: boolean
|
|
5
|
+
forPassword?: boolean
|
|
6
|
+
otherRules?: any
|
|
7
|
+
required?: boolean,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useRules(options?: UseRulesOptions) {
|
|
11
|
+
const rules = []
|
|
12
|
+
|
|
13
|
+
if (options?.required == true) {
|
|
14
|
+
rules.push((v: any) => !!v || 'Field is required')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (options?.otherRules != null) {
|
|
18
|
+
if (Array.isArray(options?.otherRules)) {
|
|
19
|
+
rules.push(...options.otherRules)
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
rules.push(options.otherRules)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (options?.forPassword == true) {
|
|
27
|
+
rules.push((x: any) => !!x || 'Password is required')
|
|
28
|
+
rules.push((x: any) => x !!= null && x.length > 9 || 'Password must be 10 or more characters')
|
|
29
|
+
rules.push((x: any) => /^(.*[a-z].*)$/.test(x) || 'Password must contain a lowercase letter')
|
|
30
|
+
rules.push((x: any) => /^(.*[A-Z].*)$/.test(x) || 'Password must contain an uppercase letter')
|
|
31
|
+
rules.push((x: any) => /^(.*\d.*)$/.test(x) || 'Password must contain a number')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (options?.forEmail == true) {
|
|
35
|
+
rules.push((v: any) => !!v || 'Email is required')
|
|
36
|
+
rules.push((v: any) => validEmail(v) || 'Email must be valid')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return rules
|
|
40
|
+
}
|