@cargolift-cdi/lib-payload 0.1.56 → 0.1.58

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.
@@ -1,6 +1,6 @@
1
- import { Schema, ValidationResult } from "./payload-validation.interface.js";
1
+ import { SchemaValidation, SchemaValidationResult } from "./payload-validation.interface.js";
2
2
  export declare class PayloadValidation {
3
- run(rawPayload: any, schema: Schema): Promise<ValidationResult>;
3
+ run(rawPayload: any, schema: SchemaValidation): Promise<SchemaValidationResult>;
4
4
  private applyValidation;
5
5
  private validateRule;
6
6
  private validateRequired;
@@ -1,6 +1,6 @@
1
- export interface SchemaValidation {
2
- field: string;
3
- type: "string" | "number" | "boolean" | "date" | "object" | "array" | "email";
1
+ export type SchemaFieldType = "string" | "number" | "boolean" | "date" | "object" | "array" | "email";
2
+ export interface Schema {
3
+ type?: SchemaFieldType;
4
4
  required?: boolean;
5
5
  length?: {
6
6
  min?: number;
@@ -18,16 +18,16 @@ export interface SchemaValidation {
18
18
  pattern?: string;
19
19
  message?: string;
20
20
  }
21
- export interface Schema {
22
- validations: SchemaValidation[];
21
+ export interface SchemaValidation {
22
+ [fieldPath: string]: Schema;
23
23
  }
24
- export interface ValidationResult {
24
+ export interface SchemaValidationResult {
25
25
  success: boolean;
26
26
  errors: {
27
27
  field: string;
28
28
  value: any;
29
29
  error: string;
30
- rule?: any;
30
+ rule?: Schema;
31
31
  }[];
32
32
  errorsList: string[];
33
33
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cargolift-cdi/lib-payload",
3
3
  "private": false,
4
- "version": "0.1.56",
4
+ "version": "0.1.58",
5
5
  "description": "Lib de tratamento e validação de payloads para serviços do middleware da Cargolift CDI",
6
6
  "license": "MIT",
7
7
  "type": "module",