@omnifyjp/ts 2.1.8 → 2.1.10

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.
@@ -73,7 +73,8 @@ const ARRAY_TYPES = new Set(['Json']);
73
73
  /** Generate validation rules for a property (Store request). */
74
74
  export function toStoreRules(property, tableName) {
75
75
  const type = property['type'] ?? 'String';
76
- const nullable = property['nullable'] ?? false;
76
+ // File type defaults to nullable (uploads are optional, attached separately)
77
+ const nullable = property['nullable'] ?? (type === 'File' ? true : false);
77
78
  const unique = property['unique'] ?? false;
78
79
  const vr = property['rules'];
79
80
  const rules = [];
@@ -223,6 +224,13 @@ function mergeValidationRules(rules, vr, type) {
223
224
  const [a, b] = vr['digitsBetween'];
224
225
  rules.push(`digits_between:${a},${b}`);
225
226
  }
227
+ // Remove max:{length} when numeric rules are present — Laravel interprets
228
+ // max as numeric comparison instead of string length when numeric/digits present
229
+ if (vr['numeric'] === true || vr['digits'] != null || vr['digitsBetween'] != null) {
230
+ const maxIdx = rules.findIndex(r => typeof r === 'string' && r.startsWith('max:'));
231
+ if (maxIdx !== -1)
232
+ rules.splice(maxIdx, 1);
233
+ }
226
234
  if (vr['startsWith'] != null) {
227
235
  const v = vr['startsWith'];
228
236
  rules.push(`starts_with:${Array.isArray(v) ? v.join(',') : v}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/ts",
3
- "version": "2.1.8",
3
+ "version": "2.1.10",
4
4
  "description": "TypeScript model type generator from Omnify schemas.json",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",