@sumaris-net/ngx-components 2.4.74 → 2.4.76

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.
@@ -3680,6 +3680,23 @@ class SharedValidators {
3680
3680
  return null;
3681
3681
  };
3682
3682
  }
3683
+ /**
3684
+ * Check precision. e.g. if precision=0.5 then value=0.6 is invalid
3685
+ * @param precision
3686
+ */
3687
+ static precision(precision) {
3688
+ if (precision)
3689
+ return (control) => {
3690
+ const value = control.value;
3691
+ if (isNil(value) || Number.isNaN(value)) {
3692
+ return null;
3693
+ }
3694
+ if (value % precision !== 0) {
3695
+ return { precision: { precision } };
3696
+ }
3697
+ return null;
3698
+ };
3699
+ }
3683
3700
  static validDate(control) {
3684
3701
  const value = control.value;
3685
3702
  const date = !value || isMoment(value) ? value : DateUtils.moment(value, DATE_ISO_PATTERN);
@@ -3817,6 +3834,7 @@ SharedValidators.I18N_ERROR_KEYS = {
3817
3834
  maxDecimals: 'ERROR.FIELD_MAXIMUM_DECIMALS',
3818
3835
  double: 'ERROR.FIELD_NOT_VALID_DOUBLE',
3819
3836
  integer: 'ERROR.FIELD_NOT_VALID_INTEGER',
3837
+ precision: 'ERROR.FIELD_NOT_VALID_PRECISION',
3820
3838
  email: 'ERROR.FIELD_NOT_VALID_EMAIL',
3821
3839
  latitude: 'ERROR.FIELD_NOT_VALID_LATITUDE',
3822
3840
  longitude: 'ERROR.FIELD_NOT_VALID_LONGITUDE',