@famgia/omnify-core 0.0.21 → 0.0.23
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/index.cjs +23 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2216,7 +2216,7 @@ function validateUnknownFieldsDetailed(propertyName, property, filePath, customT
|
|
|
2216
2216
|
)
|
|
2217
2217
|
);
|
|
2218
2218
|
} else {
|
|
2219
|
-
|
|
2219
|
+
errors.push(
|
|
2220
2220
|
validationError(
|
|
2221
2221
|
`Property '${propertyName}' has unknown field '${field}'`,
|
|
2222
2222
|
buildLocation7(filePath),
|
|
@@ -2229,16 +2229,17 @@ function validateUnknownFieldsDetailed(propertyName, property, filePath, customT
|
|
|
2229
2229
|
}
|
|
2230
2230
|
function getSuggestionForUnknownField(field) {
|
|
2231
2231
|
if (field === "required") {
|
|
2232
|
-
return `'required' is not a valid field.
|
|
2233
|
-
|
|
2232
|
+
return `'required' is not a valid field. This validation feature is not yet implemented.
|
|
2233
|
+
Properties are NOT nullable by default in the database.
|
|
2234
|
+
Use 'nullable: true' to make a field optional in the database.`;
|
|
2235
|
+
}
|
|
2236
|
+
if (field === "maxLength" || field === "minLength") {
|
|
2237
|
+
return `'${field}' is not a valid field. Use 'length' for database column size.
|
|
2238
|
+
Validation rules (minLength, maxLength, pattern, etc.) are not yet implemented.
|
|
2234
2239
|
Example:
|
|
2235
|
-
|
|
2240
|
+
name:
|
|
2236
2241
|
type: String
|
|
2237
|
-
#
|
|
2238
|
-
|
|
2239
|
-
phone:
|
|
2240
|
-
type: String
|
|
2241
|
-
nullable: true # optional field`;
|
|
2242
|
+
length: 255 # Database column size`;
|
|
2242
2243
|
}
|
|
2243
2244
|
if (field === "hidden") {
|
|
2244
2245
|
return `'hidden' is not a standard field. For Laravel, hidden fields are configured in the Model class.`;
|
|
@@ -2253,7 +2254,7 @@ Example:
|
|
|
2253
2254
|
target: User
|
|
2254
2255
|
# Creates author_id column automatically`;
|
|
2255
2256
|
}
|
|
2256
|
-
return `Valid property fields: type, displayName, nullable, default, unique, description, length, unsigned, precision, scale, enum, relation, target, onDelete, onUpdate, joinTable`;
|
|
2257
|
+
return `Unknown field '${field}'. Valid property fields: type, displayName, nullable, default, unique, description, length, unsigned, precision, scale, enum, relation, target, onDelete, onUpdate, joinTable`;
|
|
2257
2258
|
}
|
|
2258
2259
|
function validatePropertyType(propertyName, property, filePath, customTypes = []) {
|
|
2259
2260
|
const errors = [];
|
|
@@ -2596,6 +2597,18 @@ function validateSchema(schema, options = {}) {
|
|
|
2596
2597
|
}
|
|
2597
2598
|
if (schema.properties) {
|
|
2598
2599
|
for (const [name, property] of Object.entries(schema.properties)) {
|
|
2600
|
+
const propertyUnknownFields = property._unknownFields;
|
|
2601
|
+
if (propertyUnknownFields && propertyUnknownFields.length > 0) {
|
|
2602
|
+
for (const field of propertyUnknownFields) {
|
|
2603
|
+
errors.push(
|
|
2604
|
+
validationError(
|
|
2605
|
+
`Property '${name}' has unknown field '${field}'`,
|
|
2606
|
+
buildLocation7(schema.filePath),
|
|
2607
|
+
getSuggestionForUnknownField(field)
|
|
2608
|
+
)
|
|
2609
|
+
);
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2599
2612
|
const unknownFieldResult = validateUnknownFieldsDetailed(
|
|
2600
2613
|
name,
|
|
2601
2614
|
property,
|