angular-odata 0.153.0 → 0.154.0

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.
@@ -9687,13 +9687,17 @@ class ODataMetadataParser {
9687
9687
  }
9688
9688
  getAttributeValue(attributes, attributeName) {
9689
9689
  const attribute = attributes.getNamedItem(attributeName);
9690
- return attribute !== null && attribute.nodeValue ? attribute.nodeValue : undefined;
9690
+ return attribute !== null && attribute.nodeValue != null ? attribute.nodeValue : undefined;
9691
9691
  }
9692
9692
  propertyValueToNumber(attributeValue) {
9693
9693
  return attributeValue !== undefined ? Number(attributeValue) : undefined;
9694
9694
  }
9695
9695
  propertyValueToBoolean(attributeValue) {
9696
- return attributeValue !== undefined ? attributeValue === 'true' : false;
9696
+ return attributeValue !== undefined && attributeValue === 'true'
9697
+ ? true
9698
+ : attributeValue !== undefined && attributeValue === 'false'
9699
+ ? false
9700
+ : undefined;
9697
9701
  }
9698
9702
  propertyValueToDate(attributeValue) {
9699
9703
  return attributeValue !== undefined ? new Date(attributeValue) : undefined;
@@ -11819,31 +11823,37 @@ class ODataModelField {
11819
11823
  }
11820
11824
  else {
11821
11825
  const computed = this.annotatedValue(COMPUTED);
11822
- const errors = this.parser?.validate(value, { method, navigation }) || [];
11826
+ const errors = this.parser?.validate(value, { method, navigation }) ?? [];
11823
11827
  if (this.required &&
11824
11828
  (value === null || (value === undefined && method !== 'modify')) && // Is null or undefined without patch?
11825
11829
  !(computed && method === 'create') // Not (Is Computed field and create) ?
11826
11830
  ) {
11827
- errors['push'](`required`);
11831
+ if (errors.indexOf('required') === -1)
11832
+ errors.push(`required`);
11828
11833
  }
11829
11834
  if (this.maxLength !== undefined &&
11830
11835
  typeof value === 'string' &&
11831
11836
  value.length > this.maxLength) {
11832
- errors['push'](`maxlength`);
11837
+ if (errors.indexOf('maxlength') === -1)
11838
+ errors.push(`maxlength`);
11833
11839
  }
11834
11840
  if (this.minLength !== undefined &&
11835
11841
  typeof value === 'string' &&
11836
11842
  value.length < this.minLength) {
11837
- errors['push'](`minlength`);
11843
+ if (errors.indexOf('minlength') === -1)
11844
+ errors.push(`minlength`);
11838
11845
  }
11839
11846
  if (this.min !== undefined && typeof value === 'number' && value < this.min) {
11840
- errors['push'](`min`);
11847
+ if (errors.indexOf('min') === -1)
11848
+ errors.push(`min`);
11841
11849
  }
11842
11850
  if (this.max !== undefined && typeof value === 'number' && value > this.max) {
11843
- errors['push'](`max`);
11851
+ if (errors.indexOf('max') === -1)
11852
+ errors.push(`max`);
11844
11853
  }
11845
11854
  if (this.pattern !== undefined && typeof value === 'string' && !this.pattern.test(value)) {
11846
- errors['push'](`pattern`);
11855
+ if (errors.indexOf('pattern') === -1)
11856
+ errors.push(`pattern`);
11847
11857
  }
11848
11858
  return !Types.isEmpty(errors) ? errors : undefined;
11849
11859
  }