Open bizlina opened 8 years ago
I've no problem with this default behavior, but if you have a problem with that, you can do something like this:
var originalRequired = $data.Validation.EntityValidation.prototype.supportedValidations["$data.Array"].required;
$data.Validation.EntityValidation.prototype.supportedValidations["$data.Array"].required = function required(value, definedValue) {
return originalRequired.apply(this, arguments) && value.length != 0;
}
The original required of jaydata for arrays is (array != null) condition, but I think that empty array should results in a required error too, so I've rewritten that with a code I've provided to you (-:
Thanks for your answer. If i replace "$data.Array" with "$data.String" then I can stop for all key fields with type "Edm.String". So far so good. But at this point my key filed has already the value "null".
Is there a possibility to step in earlier, for example, at the point of mapping from odata to jaydata?
In the meantime I found out, that the "problem" is in the saveChanges() method of EntityContext.js. This is an excerpt of the saveChanges-method:
In the variable "memDef" in line 1387 the field is still correct filled with an empty string. In the following secquence the control flow get into the if-condition and with String as value for "memDefType" in the switch-case. In line 1404 my property get's assigned to null. As you can see here:
The empty string is technical correct and I need to display this empty string in my application. Is there a similar way to override the default value as @ymoradi provided in his answer for the validation?
Hi,
I've used JaySvcUtil to generate the entity model out of my oData service. The description is correct generated. I have multiple string keys for one Entity. A oData call for that Entity gives me, for example, the following result (the yellow marked properties are the key columns):
One of the key columns (THEME) contains an empty string. After mapping with jaydata the empty string is transformed to "null". This gives me an valildation error because the key filed is required and seems to be null. See the following screenshot.
How can I resolve this issue? Is there any possibility to tell jaydata that an empty string is okay for the a field that is defined as "Edm.String"?