@corp-products/ui-components 4.1.4 → 4.1.5
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.
|
@@ -703,6 +703,42 @@ class FormUtils {
|
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
+
/**
|
|
707
|
+
* Validator function to check if the control value is a valid email address.
|
|
708
|
+
* @returns A validator function that checks if the value is a valid email address.
|
|
709
|
+
*/
|
|
710
|
+
function emailStcValidator(allowedDomains) {
|
|
711
|
+
return (control) => {
|
|
712
|
+
const value = control.value;
|
|
713
|
+
if (!value)
|
|
714
|
+
return null;
|
|
715
|
+
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
716
|
+
// Helper function to check if email is from allowed domain
|
|
717
|
+
const isFromAllowedDomain = (email) => {
|
|
718
|
+
const domain = email.split('@')[1]?.toLowerCase();
|
|
719
|
+
return allowedDomains.some((allowedDomain) => domain === allowedDomain.toLowerCase());
|
|
720
|
+
};
|
|
721
|
+
// Helper function to validate a single email
|
|
722
|
+
const validateEmail = (email) => {
|
|
723
|
+
return emailPattern.test(email);
|
|
724
|
+
};
|
|
725
|
+
if (Array.isArray(value)) {
|
|
726
|
+
// Check if all emails are from allowed domains
|
|
727
|
+
const allFromAllowedDomains = value.every((email) => typeof email === 'string' && isFromAllowedDomain(email));
|
|
728
|
+
if (!allFromAllowedDomains) {
|
|
729
|
+
return { emailDomain: true };
|
|
730
|
+
}
|
|
731
|
+
// Validate each email
|
|
732
|
+
const allValid = value.every((email) => typeof email === 'string' && validateEmail(email));
|
|
733
|
+
return allValid ? null : { emailDomain: true };
|
|
734
|
+
}
|
|
735
|
+
// Single email validation (must match pattern AND be from allowed domain)
|
|
736
|
+
const isValid = typeof value === 'string' && validateEmail(value);
|
|
737
|
+
const allowed = typeof value === 'string' && isFromAllowedDomain(value);
|
|
738
|
+
return isValid && allowed ? null : { emailDomain: true };
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
|
|
706
742
|
var BasicErrorKeysEnum;
|
|
707
743
|
(function (BasicErrorKeysEnum) {
|
|
708
744
|
BasicErrorKeysEnum["required"] = "REQUIRED";
|
|
@@ -719,6 +755,7 @@ var BasicErrorKeysEnum;
|
|
|
719
755
|
BasicErrorKeysEnum["fileSelected"] = "FILE_SELECTED";
|
|
720
756
|
BasicErrorKeysEnum["default"] = "DEFAULT";
|
|
721
757
|
BasicErrorKeysEnum["numbersOnly"] = "NUMBERS_ONLY";
|
|
758
|
+
BasicErrorKeysEnum["invalidSaudiPhoneNumber"] = "INVALID_SAUDI_PHONE_NUMBER";
|
|
722
759
|
})(BasicErrorKeysEnum || (BasicErrorKeysEnum = {}));
|
|
723
760
|
var ErrorsWithValuesKeysEnum;
|
|
724
761
|
(function (ErrorsWithValuesKeysEnum) {
|
|
@@ -781,6 +818,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
|
|
|
781
818
|
}]
|
|
782
819
|
}] });
|
|
783
820
|
|
|
821
|
+
function numbersOnlyValidator(control) {
|
|
822
|
+
const value = control.value;
|
|
823
|
+
if (value === null || value === undefined || value === '') {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
const isNumbersOnly = /^[0-9]+$/.test(value);
|
|
827
|
+
return isNumbersOnly ? null : { numbersOnly: true };
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Validator to check if the control value is a valid Saudi phone number.
|
|
832
|
+
* Valid formats: 05XXXXXXXX (10 digits) or 009665XXXXXXXX (14 digits)
|
|
833
|
+
*/
|
|
834
|
+
function saudiPhoneValidator() {
|
|
835
|
+
return (control) => {
|
|
836
|
+
let value = control.value;
|
|
837
|
+
if (!value)
|
|
838
|
+
return null;
|
|
839
|
+
// Convert to string and trim spaces
|
|
840
|
+
value = value.toString().trim();
|
|
841
|
+
// Regex: accepts 05XXXXXXXX or 009665XXXXXXXX
|
|
842
|
+
const saudiPhoneRegex = /^(?:05\d{8}|009665\d{8})$/;
|
|
843
|
+
if (!saudiPhoneRegex.test(value)) {
|
|
844
|
+
return { invalidSaudiPhoneNumber: true };
|
|
845
|
+
}
|
|
846
|
+
return null;
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
|
|
784
850
|
class ValidationErrorsPipe {
|
|
785
851
|
formValidationService = inject(FormValidationService);
|
|
786
852
|
// allowed keys here to handle errors in case of cross-validators like startDate and endDate validators,
|
|
@@ -806,51 +872,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
|
|
|
806
872
|
}]
|
|
807
873
|
}] });
|
|
808
874
|
|
|
809
|
-
function numbersOnlyValidator(control) {
|
|
810
|
-
const value = control.value;
|
|
811
|
-
if (value === null || value === undefined || value === '') {
|
|
812
|
-
return null;
|
|
813
|
-
}
|
|
814
|
-
const isNumbersOnly = /^[0-9]+$/.test(value);
|
|
815
|
-
return isNumbersOnly ? null : { numbersOnly: true };
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* Validator function to check if the control value is a valid email address.
|
|
820
|
-
* @returns A validator function that checks if the value is a valid email address.
|
|
821
|
-
*/
|
|
822
|
-
function emailStcValidator(allowedDomains) {
|
|
823
|
-
return (control) => {
|
|
824
|
-
const value = control.value;
|
|
825
|
-
if (!value)
|
|
826
|
-
return null;
|
|
827
|
-
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
828
|
-
// Helper function to check if email is from allowed domain
|
|
829
|
-
const isFromAllowedDomain = (email) => {
|
|
830
|
-
const domain = email.split('@')[1]?.toLowerCase();
|
|
831
|
-
return allowedDomains.some((allowedDomain) => domain === allowedDomain.toLowerCase());
|
|
832
|
-
};
|
|
833
|
-
// Helper function to validate a single email
|
|
834
|
-
const validateEmail = (email) => {
|
|
835
|
-
return emailPattern.test(email);
|
|
836
|
-
};
|
|
837
|
-
if (Array.isArray(value)) {
|
|
838
|
-
// Check if all emails are from allowed domains
|
|
839
|
-
const allFromAllowedDomains = value.every((email) => typeof email === 'string' && isFromAllowedDomain(email));
|
|
840
|
-
if (!allFromAllowedDomains) {
|
|
841
|
-
return { emailDomain: true };
|
|
842
|
-
}
|
|
843
|
-
// Validate each email
|
|
844
|
-
const allValid = value.every((email) => typeof email === 'string' && validateEmail(email));
|
|
845
|
-
return allValid ? null : { emailDomain: true };
|
|
846
|
-
}
|
|
847
|
-
// Single email validation (must match pattern AND be from allowed domain)
|
|
848
|
-
const isValid = typeof value === 'string' && validateEmail(value);
|
|
849
|
-
const allowed = typeof value === 'string' && isFromAllowedDomain(value);
|
|
850
|
-
return isValid && allowed ? null : { emailDomain: true };
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
|
-
|
|
854
875
|
class AutoCompleteComponent extends BaseInputComponent {
|
|
855
876
|
selectedItemTemplate = null;
|
|
856
877
|
// eslint-disable-next-line @angular-eslint/no-output-on-prefix
|
|
@@ -2883,5 +2904,5 @@ const notFutureDateValidator = (dateKey) => (control) => {
|
|
|
2883
2904
|
* Generated bundle index. Do not edit.
|
|
2884
2905
|
*/
|
|
2885
2906
|
|
|
2886
|
-
export { AlertDialogComponent, AlertDialogService, AppAccordionComponent, AppBreadcrumbComponent, AppButtonComponent, AppDropdownMenuComponent, AppTabsComponent, AutoCompleteComponent, BasicErrorKeysEnum, BottomSheetComponent, ConfirmationDialogComponent, ConfirmationDialogService, DatePickerComponent, DualCalendarComponent, DynamicFormComponent, DynamicSidebarService, DynamicSidebarV2Service, ErrorsWithValuesKeysEnum, FormFieldTypeEnum, FormUtils, FormValidationService, IcoMoonIconComponent, InputComponent, MONTHS_GREGORIAN, MONTHS_HIJRI, ReadMoreComponent, SelectButtonComponent, SelectComponent, SideBarComponent, SidebarConfigDefaults, SwitchComponent, UploadStatus, UserAutocompleteCardComponent, UserInfoComponent, ValidationErrorsPipe, WEEKDAYS, dateRangeValidator, emailStcValidator, getGregorianMonthName, getHijriMonthName, getWeekdayName, notFutureDateValidator, numbersOnlyValidator };
|
|
2907
|
+
export { AlertDialogComponent, AlertDialogService, AppAccordionComponent, AppBreadcrumbComponent, AppButtonComponent, AppDropdownMenuComponent, AppTabsComponent, AutoCompleteComponent, BasicErrorKeysEnum, BottomSheetComponent, ConfirmationDialogComponent, ConfirmationDialogService, DatePickerComponent, DualCalendarComponent, DynamicFormComponent, DynamicSidebarService, DynamicSidebarV2Service, ErrorsWithValuesKeysEnum, FormFieldTypeEnum, FormUtils, FormValidationService, IcoMoonIconComponent, InputComponent, MONTHS_GREGORIAN, MONTHS_HIJRI, ReadMoreComponent, SelectButtonComponent, SelectComponent, SideBarComponent, SidebarConfigDefaults, SwitchComponent, UploadStatus, UserAutocompleteCardComponent, UserInfoComponent, ValidationErrorsPipe, WEEKDAYS, dateRangeValidator, emailStcValidator, getGregorianMonthName, getHijriMonthName, getWeekdayName, notFutureDateValidator, numbersOnlyValidator, saudiPhoneValidator };
|
|
2887
2908
|
//# sourceMappingURL=corp-products-ui-components.mjs.map
|