safeshield 1.0.7__py3-none-any.whl → 1.0.8__py3-none-any.whl

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.

Potentially problematic release.


This version of safeshield might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: safeshield
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: Library for Help Validation Control
5
5
  Home-page: https://github.com/WunsunTarniho/py-guard
6
6
  Author: Wunsun Tarniho
@@ -48,3 +48,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
48
48
 
49
49
  ## v1.0.7 (2024-07-20)
50
50
  - Fixed: Libary deprecated.
51
+
52
+ ## v1.0.8 (2024-07-20)
53
+ - Fixed: Libary deprecated.
@@ -8,7 +8,7 @@ validator/database/detector.py,sha256=mPNZlOgwNBPNwL_XcKSmT6H5Bq370nMkqqMMOqkM9W
8
8
  validator/database/manager.py,sha256=Ezz4NUh22Hz2puh-NJggSGCaw3lAGyp3V88plMeBBVU,6232
9
9
  validator/rules/__init__.py,sha256=nDE3qoI82qJTCbILLUWkXuwsMOmsDtB1m-3IGIvRfpY,919
10
10
  validator/rules/array.py,sha256=tx8FCDqn-27Vs7tgtjeoCE9ceDMVrdBEb2-pq-lNLuo,2809
11
- validator/rules/base.py,sha256=i1CPoBJWhT7VgqdryOF74mvM6AxrFLCYMC9ZmFxjKxc,2887
11
+ validator/rules/base.py,sha256=hrGESfkdvqZrQ1yIK_ftVVOMUuyvNFoz-_qaqUucSy8,3474
12
12
  validator/rules/basic.py,sha256=fMk0s5_IEQu27X1wndP_ocNyOZ1upXJCn7fR9YYbI74,1527
13
13
  validator/rules/comparison.py,sha256=9xb2mO5GiThR1iO8867ex2o7olQC2Bnew6MBdD2UtEo,9402
14
14
  validator/rules/conditional.py,sha256=8_O1etzCyCGeD8lmfhegJ1uzhkBSjTEVdufbZmkqgP4,12993
@@ -24,8 +24,8 @@ validator/services/rule_error_handler.py,sha256=MGvvkP6hbZLpVXxC3xpzg15OmVdPlk7l
24
24
  validator/services/rule_preparer.py,sha256=jRcMNjqq2xyZjO64Pim8jWmja5DmTzf0V_uuHG0lJTg,5621
25
25
  validator/utils/__init__.py,sha256=Yzo-xv285Be-a233M4duDdYtscuHiuBbPSX_C8yViJI,20
26
26
  validator/utils/string.py,sha256=0YACzeEaWNEOR9_7O9A8D1ItIbtWfOJ8IfrzcB8VMYA,515
27
- safeshield-1.0.7.dist-info/LICENSE,sha256=qugtRyKckyaks6hd2xyxOFSOYM6au1N80pMXuMTPvC4,1090
28
- safeshield-1.0.7.dist-info/METADATA,sha256=_g3F2vloXN1CrOxeE5NYqY9KD5IKEngAED4fsA648V4,1538
29
- safeshield-1.0.7.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
- safeshield-1.0.7.dist-info/top_level.txt,sha256=iUtV3dlHOIiMfLuY4pruY00lFni8JzOkQ3Nh1II19OE,10
31
- safeshield-1.0.7.dist-info/RECORD,,
27
+ safeshield-1.0.8.dist-info/LICENSE,sha256=qugtRyKckyaks6hd2xyxOFSOYM6au1N80pMXuMTPvC4,1090
28
+ safeshield-1.0.8.dist-info/METADATA,sha256=EkziodcnGss5kWdAO1I3WBZ5EaTKpHK2v1tkBJsGoh0,1593
29
+ safeshield-1.0.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
+ safeshield-1.0.8.dist-info/top_level.txt,sha256=iUtV3dlHOIiMfLuY4pruY00lFni8JzOkQ3Nh1II19OE,10
31
+ safeshield-1.0.8.dist-info/RECORD,,
validator/rules/base.py CHANGED
@@ -1,8 +1,9 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from typing import Any, Dict, List, Optional, Set, Union, Tuple, Type
3
3
  from enum import Enum
4
- from .string import pascal_to_snake
4
+ # from .string import pascal_to_snake
5
5
  import inspect
6
+ import re
6
7
 
7
8
  class ValidationRule(ABC):
8
9
  """Abstract base class for all validation rules"""
@@ -12,7 +13,7 @@ class ValidationRule(ABC):
12
13
  self._params: List[str] = list(params)
13
14
 
14
15
  def __init_subclass__(cls):
15
- cls.rule_name = pascal_to_snake(cls.__name__)
16
+ cls.rule_name = cls.pascal_to_snake(cls.__name__)
16
17
 
17
18
  @property
18
19
  def params(self) -> List[str]:
@@ -81,4 +82,20 @@ class ValidationRule(ABC):
81
82
 
82
83
  param_str = ' ,'.join(params)
83
84
 
84
- return [v.strip() for v in param_str.split(',') if v.strip()]
85
+ return [v.strip() for v in param_str.split(',') if v.strip()]
86
+
87
+ def pascal_to_snake(name):
88
+ """Convert PascalCase to snake_case"""
89
+ # Handle kasus khusus terlebih dahulu
90
+ special_cases = {
91
+ 'UUIDRule': 'uuid',
92
+ 'IPRule': 'ip',
93
+ 'URLRule': 'url'
94
+ }
95
+ if name in special_cases:
96
+ return special_cases[name]
97
+
98
+ # Konversi regular PascalCase ke snake_case
99
+ s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
100
+ result = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
101
+ return result.replace('_rule', '')