perfect-payload 1.0.5 → 1.0.6

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.
Files changed (2) hide show
  1. package/README.md +8 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ This module provides a robust framework for validating data objects based on def
11
11
  5. [Default Values](#default-values)
12
12
  6. [Examples and Usage](#default-values)
13
13
 
14
- ## 1. Quick Signht
14
+ ## 1. Quick Sights
15
15
 
16
16
  usage:
17
17
 
@@ -24,8 +24,8 @@ input:
24
24
 
25
25
  1. **data :** your payload object (required *)
26
26
  2. **dataValidationRule:** validation rule object (required *)
27
- 3. **validPayloadResponse:** response you want if all attribute validation passed (Optional)
28
- 4. **inValidPayloadResponse:** response you want any validation fails (Optional)
27
+ 3. **validPayloadResponse:** response object you want it back on all validation passed (Optional)
28
+ 4. **inValidPayloadResponse:** response object you want it back on any validation fails (Optional)
29
29
 
30
30
  **Default Valid Payload Response:**
31
31
 
@@ -36,18 +36,18 @@ input:
36
36
  }
37
37
  ```
38
38
 
39
-
40
- **Default In-Valid Payload Response:**
39
+ **Default Invalid Payload Response:**
41
40
 
42
41
  ```javascript
43
42
  {
44
43
  statusCode:400,
45
44
  valid:false,
46
45
  message:"One or more attribute values are invalid",
47
- errors:["array of each attribute error messages"]
46
+ errors:["minSalary must be less than maxSalary"]
48
47
  }
49
48
  ```
50
49
 
50
+ **Note:** If inValidPayloadResponse is passed, then it will be returned along with errors property(avoid proper attribute in your inValidPayloadResponse object)
51
51
 
52
52
  ## 2. Available Validation Attributes
53
53
 
@@ -123,7 +123,6 @@ If not explicitly specified, the following default values are applied:
123
123
  - **objectAttr**: Ignored.
124
124
  - **dependency**: Ignored.
125
125
 
126
-
127
126
  ## 6. Examples And Usage
128
127
 
129
128
  ### 1. Sample Validation Rule
@@ -137,6 +136,7 @@ sample-1
137
136
  allowNull: false,
138
137
  type: "string",
139
138
  minLength: 3,
139
+ minLengthError:"First name must have minimum 3 characters."
140
140
  },
141
141
  lastName: {
142
142
  mandatory: false,
@@ -162,11 +162,10 @@ sample-1
162
162
  };
163
163
  ```
164
164
 
165
-
166
-
167
165
  sample-2
168
166
 
169
167
  ```javascript
168
+
170
169
  {
171
170
  id: {
172
171
  mandatory: true,
@@ -303,13 +302,10 @@ sample-2
303
302
  }
304
303
  ```
305
304
 
306
-
307
-
308
305
  ### 2. Usage
309
306
 
310
307
  #### 1. creating your route with middleware and validation rule:
311
308
 
312
-
313
309
  ```javascript
314
310
  //Here validatePayload is your middleware function where you're invoking perfect payload
315
311
  router.post(
@@ -334,7 +330,6 @@ export const validatePayload = ({ rule }) => {
334
330
  };
335
331
  ```
336
332
 
337
-
338
333
  #### Usage in venila js code
339
334
 
340
335
  ```javascript
@@ -344,7 +339,6 @@ console.log(result?.statusCode)
344
339
  console.log(result?.isValid)
345
340
  ```
346
341
 
347
-
348
342
  ---
349
343
 
350
344
  This documentation provides a comprehensive guide to using the data validation module effectively. Ensure to define your validation rules clearly to maintain data quality and consistency in your applications.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perfect-payload",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "description": "JSON Data Validation",
6
6
  "main": "index.js",