You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add declarative validation helpers and pre-built scalars
- Add validators module with string, number, array, and date validators
- Add scalars module with pre-built validated scalars (Email, URL, PositiveInt, PositiveFloat)
- Add factory functions for creating custom bounded and pattern-based scalars
- Update README with comprehensive documentation
- Add comprehensive test coverage for validators and scalars
- `validators.stringLength(name, min, max)` - Validates string length with min/max bounds (required for CREATE)
1202
+
- `validators.maxLength(name, max)` - Validates maximum string length
1203
+
- `validators.pattern(name, regex, message)` - Validates against a regex pattern
1204
+
- `validators.email()` - Validates email format
1205
+
- `validators.url()` - Validates URL format
1206
+
1207
+
**Number Validators:**
1208
+
- `validators.numberRange(name, min, max)` - Validates number range
1209
+
- `validators.positive(name)` - Ensures number is positive
1210
+
1211
+
**Array Validators:**
1212
+
- `validators.arrayLength(name, maxItems, itemValidator)` - Validates array length and optionally each item
1213
+
1214
+
**Date Validators:**
1215
+
- `validators.dateFormat(name, format)` - Validates date format
1216
+
- `validators.futureDate(name)` - Ensures date is in the future
1217
+
1218
+
#### Validator Features
1219
+
1220
+
- **Automatic Operation Handling**: Validators work for both `CREATE` (save) and `UPDATE` operations
1221
+
- **Smart Validation**: For CREATE operations, values are required. For UPDATE operations, undefined/null values are allowed (field might not be updated)
1222
+
- **Consistent Error Messages**: All validators throw `SimfinityError` with appropriate messages
0 commit comments