@candlerip/shared3 0.0.97 → 0.0.99
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/ssr/server-side-props/candles-page-server-side-props.type.d.ts +2 -0
- package/src/type/array/index.d.ts +1 -0
- package/src/type/array/index.js +1 -0
- package/src/type/array/validate.d.ts +6 -0
- package/src/type/array/validate.js +16 -0
- package/src/type/string/index.d.ts +1 -0
- package/src/type/string/index.js +1 -0
- package/src/type/string/validate-comma-separated-string/index.d.ts +2 -0
- package/src/type/string/validate-comma-separated-string/index.js +17 -0
- package/src/type/string/validate-comma-separated-string/types.d.ts +6 -0
- package/src/type/string/validate-comma-separated-string/types.js +1 -0
package/package.json
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
import { Auth } from '../../auth/index.js';
|
2
2
|
import { CookieConsent } from '../../cookie/index.js';
|
3
3
|
import { Dictionary, Language } from '../../dictionary/index.js';
|
4
|
+
import { CandleFilterSort } from '../../filter-sort/index.js';
|
4
5
|
import { CandlesPageData } from '../../page/index.js';
|
5
6
|
export interface CandlesPageServerSideProps {
|
6
7
|
auth: Auth;
|
7
8
|
cookieConsent?: CookieConsent;
|
8
9
|
dictionary: Dictionary;
|
10
|
+
filterSort: CandleFilterSort;
|
9
11
|
language: Language;
|
10
12
|
pageData: CandlesPageData;
|
11
13
|
}
|
package/src/type/array/index.js
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
import { customErrorWorker } from '../../error/index.js';
|
2
|
+
export const validateArray = (data, name, valid) => {
|
3
|
+
const { composeCustomError } = customErrorWorker({ data, name, valid });
|
4
|
+
if (!data) {
|
5
|
+
return composeCustomError(`Missing ${name}`);
|
6
|
+
}
|
7
|
+
if (!Array.isArray(data)) {
|
8
|
+
return composeCustomError(`Invalid ${name}`);
|
9
|
+
}
|
10
|
+
if (!data.every((it) => valid.includes(it))) {
|
11
|
+
return composeCustomError(`Invalid ${name}`);
|
12
|
+
}
|
13
|
+
return {
|
14
|
+
data,
|
15
|
+
};
|
16
|
+
};
|
package/src/type/string/index.js
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
import { customErrorWorker } from '../../../error/index.js';
|
2
|
+
import { validateArray } from '../../array/index.js';
|
3
|
+
import { isString } from '../type-guard.js';
|
4
|
+
export const validateCommaSeparatedString = (data, name, valid) => {
|
5
|
+
const { composeCustomError } = customErrorWorker({ data, name, valid });
|
6
|
+
if (!data) {
|
7
|
+
return composeCustomError(`Missing ${name}`);
|
8
|
+
}
|
9
|
+
if (!isString(data)) {
|
10
|
+
return composeCustomError(`${name} not string`);
|
11
|
+
}
|
12
|
+
const parsedArr = data.split(',');
|
13
|
+
if (parsedArr.length === 0) {
|
14
|
+
return composeCustomError(`Invalid ${name}`);
|
15
|
+
}
|
16
|
+
return validateArray(parsedArr, name, valid);
|
17
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|