@rxap/forms 13.0.6 → 13.1.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.
@@ -14,7 +14,7 @@ import { ToggleSubject } from '@rxap/utilities/rxjs';
14
14
  import * as i2$1 from '@angular/router';
15
15
  import { Router } from '@angular/router';
16
16
  import { ConfirmClick } from '@rxap/directives';
17
- import { isMobilePhone, isEmail, isURL, isIP } from '@rxap/validator';
17
+ import { isMobilePhone, isEmail, isURL, isIP, isPort, isUUID } from '@rxap/validator';
18
18
 
19
19
  function getControlValue(control) {
20
20
  if (control.getRawValue) {
@@ -1235,12 +1235,6 @@ class FormDirective extends FormGroupDirective {
1235
1235
  return this._formDefinition;
1236
1236
  }
1237
1237
  ngOnChanges(changes) {
1238
- // depending on the usage the member from is set after another member
1239
- // triggers the ngOnChanges hook. to prevent an "angular" exception
1240
- // the ngOnChanges is skipped if the member form is not set
1241
- if (!this.form) {
1242
- return;
1243
- }
1244
1238
  super.ngOnChanges(changes);
1245
1239
  const formChange = changes.form;
1246
1240
  if (formChange && !formChange.firstChange) {
@@ -2738,6 +2732,42 @@ function IsIP({ message, version } = {}) {
2738
2732
  };
2739
2733
  }
2740
2734
 
2735
+ function IsPort({ message } = {}) {
2736
+ return (control) => {
2737
+ if (control.value === null) {
2738
+ return null;
2739
+ }
2740
+ if (!(typeof control.value === 'string' && isPort(control.value))) {
2741
+ return {
2742
+ isPort: {
2743
+ expected: `A valid port number between 1 and 65535`,
2744
+ actual: control.value,
2745
+ message
2746
+ }
2747
+ };
2748
+ }
2749
+ return null;
2750
+ };
2751
+ }
2752
+
2753
+ function IsUUID({ message, version = 'all' } = {}) {
2754
+ return (control) => {
2755
+ if (control.value === null) {
2756
+ return null;
2757
+ }
2758
+ if (!(typeof control.value === 'string' && isUUID(control.value, version))) {
2759
+ return {
2760
+ isUuid: {
2761
+ expected: version === 'all' ? `A valid uuid` : `A valid uuid version ${version}`,
2762
+ actual: control.value,
2763
+ message
2764
+ }
2765
+ };
2766
+ }
2767
+ return null;
2768
+ };
2769
+ }
2770
+
2741
2771
  const RxapValidators = {
2742
2772
  IsNumber: _IsNumber,
2743
2773
  IsBoolean,
@@ -2751,7 +2781,9 @@ const RxapValidators = {
2751
2781
  IsPhoneNumber,
2752
2782
  IsEmail,
2753
2783
  IsUrl,
2754
- IsIP
2784
+ IsIP,
2785
+ IsPort,
2786
+ IsUUID,
2755
2787
  };
2756
2788
 
2757
2789
  // endregion