Comparing version 2.16.6 to 2.16.7
@@ -136,2 +136,7 @@ /* UNIQORM | ||
value = value == null ? null : value; | ||
this.validateValue(value); | ||
return value; | ||
} | ||
validateValue(value) { | ||
if (this.validate) { | ||
@@ -144,3 +149,2 @@ try { | ||
} | ||
return value; | ||
} | ||
@@ -147,0 +151,0 @@ |
@@ -719,16 +719,10 @@ /* UNIQORM | ||
// Validate required | ||
if (field.required && field.defaultValue == null && | ||
( | ||
(options.forCreate && v == null) || | ||
(!options.forCreate && v !== undefined) | ||
) | ||
if (field.required && field.defaultValue == null && v == null && | ||
(options.forCreate || v !== undefined) | ||
) { | ||
if (v == null && field.required && field.defaultValue == null) { | ||
throw new ValidationError('Value required for "%s"', name) | ||
.set({ | ||
reason: 'value_required', | ||
field: name | ||
}); | ||
} | ||
throw new ValidationError('Value required for "%s"', name) | ||
.set({ | ||
reason: 'value_required', | ||
field: name | ||
}); | ||
} | ||
@@ -747,2 +741,3 @@ if (v != null) { | ||
} | ||
field.validateValue(v); | ||
} | ||
@@ -763,5 +758,10 @@ } | ||
continue; | ||
const v = values[name]; | ||
let v = values[name]; | ||
if (v !== undefined) { | ||
v = field.parseValue(v); | ||
if (v == null && field.defaultValue != null) | ||
v = field.defaultValue; | ||
} | ||
if (v !== undefined) | ||
result[field.fieldName] = field.parseValue(v); | ||
result[field.fieldName] = v; | ||
} | ||
@@ -768,0 +768,0 @@ return result; |
{ | ||
"name": "uniqorm", | ||
"description": "Multi dialect and multi schema ORM framework for enterprise level NodeJS applications", | ||
"version": "2.16.6", | ||
"version": "2.16.7", | ||
"author": "Panates Ltd.", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
100422
3293