s3db.js 13.3.1 → 13.5.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.
package/README.md CHANGED
@@ -137,6 +137,8 @@ console.log("🎉 Connected to S3 database!");
137
137
 
138
138
  ### 3. Create your first resource
139
139
 
140
+ Schema validation powered by **[fastest-validator](https://github.com/icebob/fastest-validator)** ⚡
141
+
140
142
  ```javascript
141
143
  const users = await s3db.createResource({
142
144
  name: "users",
@@ -718,7 +720,7 @@ await users.insert({ email: 'john@example.com', password: 'secret123', age: 25 }
718
720
 
719
721
  ### Schema & Field Types
720
722
 
721
- Define your data structure with powerful validation:
723
+ Define your data structure with powerful validation using **[fastest-validator](https://github.com/icebob/fastest-validator)** - a blazing-fast validation library with comprehensive type support:
722
724
 
723
725
  #### Basic Types
724
726
 
@@ -749,6 +751,9 @@ Define your data structure with powerful validation:
749
751
 
750
752
  #### Schema Examples
751
753
 
754
+ > **📖 Validation powered by [fastest-validator](https://github.com/icebob/fastest-validator)**
755
+ > All schemas use fastest-validator's syntax with full support for shorthand notation.
756
+
752
757
  ```javascript
753
758
  // Simple schema
754
759
  {
@@ -757,21 +762,40 @@ Define your data structure with powerful validation:
757
762
  age: 'number|integer|min:0|max:150'
758
763
  }
759
764
 
760
- // Nested objects
765
+ // Nested objects - MAGIC AUTO-DETECT! ✨ (recommended)
766
+ // Just write your object structure - s3db detects it automatically!
767
+ {
768
+ name: 'string|required',
769
+ profile: { // ← No $$type needed! Auto-detected as optional object
770
+ bio: 'string|max:500',
771
+ avatar: 'url|optional',
772
+ social: { // ← Deeply nested also works!
773
+ twitter: 'string|optional',
774
+ github: 'string|optional'
775
+ }
776
+ }
777
+ }
778
+
779
+ // Need validation control? Use $$type (when you need required/optional)
780
+ {
781
+ name: 'string|required',
782
+ profile: {
783
+ $$type: 'object|required', // ← Add required validation
784
+ bio: 'string|max:500',
785
+ avatar: 'url|optional'
786
+ }
787
+ }
788
+
789
+ // Advanced: Full control (rare cases - strict mode, etc)
761
790
  {
762
791
  name: 'string|required',
763
792
  profile: {
764
793
  type: 'object',
794
+ optional: false,
795
+ strict: true, // ← Enable strict validation
765
796
  props: {
766
797
  bio: 'string|max:500',
767
- avatar: 'url|optional',
768
- social: {
769
- type: 'object',
770
- props: {
771
- twitter: 'string|optional',
772
- github: 'string|optional'
773
- }
774
- }
798
+ avatar: 'url|optional'
775
799
  }
776
800
  }
777
801
  }