|
1 | 1 | from .base_validator import BaseValidator |
2 | 2 | from .gcmd_validator import GcmdValidator |
3 | 3 | from .utils import cmr_request, collection_in_cmr, if_arg, set_cmr_prms |
4 | | - |
| 4 | +import re |
5 | 5 |
|
6 | 6 | class StringValidator(BaseValidator): |
7 | 7 | """ |
@@ -38,15 +38,21 @@ def length_check(string, extent, relation): |
38 | 38 | def compare(first, second, relation): |
39 | 39 | """ |
40 | 40 | Compares two strings based on the relationship |
41 | | -
|
42 | 41 | Returns: |
43 | | - (dict) An object with the validity of the check and the instance |
| 42 | + (dict) An object with the validity of the check and the instance |
44 | 43 | """ |
| 44 | + |
| 45 | + # Check if 'first' and 'second' contain any special characters |
| 46 | + first_clean = re.sub(r'[^a-zA-Z0-9]', '', first).upper() |
| 47 | + second_clean = re.sub(r'[^a-zA-Z0-9]', '', second).upper() |
| 48 | + |
| 49 | + # If either string contains special characters, return a warning or handle as needed |
45 | 50 | return { |
46 | | - "valid": BaseValidator.compare(first.upper(), second.upper(), relation), |
| 51 | + "valid": BaseValidator.compare(first_clean, second_clean, relation), |
47 | 52 | "value": (first, second), |
48 | 53 | } |
49 | 54 |
|
| 55 | + |
50 | 56 | @staticmethod |
51 | 57 | @if_arg |
52 | 58 | def controlled_keywords_check(value, keywords_list): |
|
0 commit comments