@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.
- package/dist/php/type-mapper.js +9 -1
- package/package.json +1 -1
package/dist/php/type-mapper.js
CHANGED
|
@@ -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
|
-
|
|
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}`);
|