perfect-payload 1.2.0-beta.0 → 1.2.0-beta.1

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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +2 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -179,7 +179,7 @@ object.
179
179
 
180
180
  ### `mandatory`
181
181
 
182
- Marks a field as required.
182
+ Marks a field as required(even empty string also not allowed)
183
183
 
184
184
  **Default:** `false`, the field is not required.
185
185
 
package/index.js CHANGED
@@ -578,7 +578,7 @@ function perfectPayloadStructured(
578
578
  // ==================================================
579
579
 
580
580
  case "mandatory":
581
- if (isMandatoryField && !attrExist) {
581
+ if (isMandatoryField && (!attrExist || attributeValue === "")) {
582
582
  addNextError = false;
583
583
 
584
584
  addStructuredError(
@@ -599,7 +599,7 @@ function perfectPayloadStructured(
599
599
  // ==================================================
600
600
 
601
601
  case "allowNull":
602
- if (addNextError && attributeValue == null) {
602
+ if (addNextError && attributeValue === null) {
603
603
  if (!attributeRules?.[ruleName]) {
604
604
  addNextError = false;
605
605
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perfect-payload",
3
- "version": "1.2.0-beta.0",
3
+ "version": "1.2.0-beta.1",
4
4
  "type": "module",
5
5
  "description": "rich json validator",
6
6
  "main": "index.js",