@anov/cic-standard-sdk 0.0.6 → 0.0.7

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.
@@ -7,3 +7,10 @@ import Ajv from 'ajv';
7
7
  export declare const getAjv: () => Ajv;
8
8
  export declare const getValidator: (ref: string) => any;
9
9
  export declare const getValidatorByType: (typeName: string) => any;
10
+ export declare const validateByType: (typeName: string, data: unknown) => {
11
+ ok: boolean;
12
+ errors?: undefined;
13
+ } | {
14
+ ok: boolean;
15
+ errors: import("./common").FormattedError[];
16
+ };
@@ -6,14 +6,20 @@
6
6
  export type Result<T> = {
7
7
  ok: boolean;
8
8
  value?: T;
9
- errors?: any[];
9
+ errors?: FormattedError[];
10
10
  };
11
- export type CreateOptions = {
12
- defaults?: Record<string, any>;
11
+ export type CreateOptions<T = any> = {
12
+ defaults?: Partial<T>;
13
13
  generateId?: boolean;
14
14
  strict?: boolean;
15
15
  throw?: boolean;
16
16
  };
17
+ export type FormattedError = {
18
+ path: string;
19
+ message: string;
20
+ keyword?: string;
21
+ params?: Record<string, any>;
22
+ };
17
23
  /** 将值规范为数组 */
18
24
  export declare const ensureArray: <T>(v: any) => T[];
19
25
  /** 判断为有限正数 */
@@ -24,3 +30,4 @@ export declare const uuid: () => any;
24
30
  export declare const httpUrl: (s: any, fallback?: string) => string;
25
31
  /** 规范 ws(s) 链接 */
26
32
  export declare const wsUrl: (s: any, fallback?: string) => string;
33
+ export declare const formatAjvErrors: (errs: any[]) => FormattedError[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anov/cic-standard-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "CIC Standard SDK with TypeScript support",
5
5
  "main": "dist/cic-sdk.cjs.js",
6
6
  "module": "dist/cic-sdk.es.js",