@sumaris-net/ngx-components 2.4.74 → 2.4.75
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/doc/changelog.md +11 -0
- package/esm2020/src/app/shared/validator/validators.mjs +18 -1
- package/fesm2015/sumaris-net.ngx-components.mjs +17 -0
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +17 -0
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/validator/validators.d.ts +5 -0
|
@@ -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);
|