@thzero/library_client_svelte 0.15.7 → 0.15.8
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/boot/baseValidation.js +54 -0
- package/package.json +2 -2
- package/service/baseUser.js +49 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class BaseValidate {
|
|
2
|
+
// eslint-disable-next-line
|
|
3
|
+
async execute(Vue, app, router) {
|
|
4
|
+
// extend('decimal', {
|
|
5
|
+
// validate: (value, { decimals = '*', separator = '.' } = {}) => {
|
|
6
|
+
// if (value === null || value === undefined || value === '') {
|
|
7
|
+
// return {
|
|
8
|
+
// valid: false
|
|
9
|
+
// };
|
|
10
|
+
// }
|
|
11
|
+
// if (Number(decimals) === 0) {
|
|
12
|
+
// return {
|
|
13
|
+
// valid: /^-?\d*$/.test(value)
|
|
14
|
+
// };
|
|
15
|
+
// }
|
|
16
|
+
// const regexPart = decimals === '*' ? '+' : `{1,${decimals}}`;
|
|
17
|
+
// const regex = new RegExp(`^[-+]?\\d*(\\${separator}\\d${regexPart})?([eE]{1}[-]?\\d+)?$`);
|
|
18
|
+
// return {
|
|
19
|
+
// valid: regex.test(value),
|
|
20
|
+
// data: {
|
|
21
|
+
// serverMessage: 'Only decimal values are available'
|
|
22
|
+
// }
|
|
23
|
+
// };
|
|
24
|
+
// },
|
|
25
|
+
// message: '{serverMessage}'
|
|
26
|
+
// });
|
|
27
|
+
|
|
28
|
+
// extend('name', {
|
|
29
|
+
// getMessage: field => 'The ' + field + ' field may only contain alphanumeric and space characters',
|
|
30
|
+
// // eslint-disable-next-line
|
|
31
|
+
// validate(value, args) {
|
|
32
|
+
// const regEx = /^[a-zA-Z0-9]+(['\-a-zA-Z0-9 ]*)*$/;
|
|
33
|
+
// return regEx.test(value);
|
|
34
|
+
// }
|
|
35
|
+
// });
|
|
36
|
+
|
|
37
|
+
// extend('tagLine', {
|
|
38
|
+
// getMessage: field => 'The ' + field + ' field may only contain alphanumeric, space, and punctuation characters',
|
|
39
|
+
// // eslint-disable-next-line
|
|
40
|
+
// validate(value, args) {
|
|
41
|
+
// const regEx = /^[a-zA-Z0-9]+([',.!& \-a-zA-Z0-9 ]*)*$/;
|
|
42
|
+
// return regEx.test(value);
|
|
43
|
+
// }
|
|
44
|
+
// });
|
|
45
|
+
|
|
46
|
+
this._initialize();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line
|
|
50
|
+
_initialize(extend) {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default BaseValidate;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_client_svelte",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.8",
|
|
4
4
|
"version_major": 0,
|
|
5
5
|
"version_minor": 15,
|
|
6
|
-
"version_patch":
|
|
6
|
+
"version_patch": 8,
|
|
7
7
|
"version_date": "12/06/2022",
|
|
8
8
|
"description": "An opinionated library of common functionality to bootstrap a Svelte based SPA application.",
|
|
9
9
|
"author": "thZero",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import LibraryConstants from '@thzero/library_client/constants';
|
|
2
|
+
|
|
3
|
+
import BaseUserService from '@thzero/library_client/service/baseUser';
|
|
4
|
+
|
|
5
|
+
class VueBaseUserService extends BaseUserService {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this._serviceStore = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async init(injector) {
|
|
13
|
+
await super.init(injector);
|
|
14
|
+
|
|
15
|
+
this._serviceStore = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_STORE);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async resetUser(correlationId) {
|
|
19
|
+
await this._serviceStore.dispatcher.user.resetUser(correlationId);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async setAuthCompleted(correlationId) {
|
|
23
|
+
await this._serviceStore.dispatcher.user.setAuthCompleted(correlationId, true);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async setClaims(correlationId, claims) {
|
|
27
|
+
await this._serviceStore.dispatcher.user.setClaims(correlationId, claims);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async setLoggedIn(correlationId, value) {
|
|
31
|
+
await this._serviceStore.dispatcher.user.setLoggedIn(correlationId, value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async setTokenResult(correlationId, tokenResult) {
|
|
35
|
+
await this._serviceStore.dispatcher.user.setTokenResult(correlationId, tokenResult);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async setUser(correlationId, user) {
|
|
39
|
+
await this._serviceStore.dispatcher.user.setUser(correlationId, user);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get token() {
|
|
43
|
+
if (this._serviceStore.state.user)
|
|
44
|
+
return this._serviceStore.state.user.token;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default VueBaseUserService;
|