pytastic 0.0.1__tar.gz → 0.0.3__tar.gz

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.
pytastic-0.0.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tersoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,7 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytastic
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: A dependency-free JSON validation library using TypedDict and Annotated
5
+ License-File: LICENSE
5
6
  Author: Tersoo
6
7
  Author-email: tersoo@example.com
7
8
  Requires-Python: >=3.9,<4.0
@@ -16,14 +17,14 @@ Description-Content-Type: text/markdown
16
17
 
17
18
  # Pytastic
18
19
 
19
- A dependency-free, high-performance JSON validation library using Python's native `TypedDict` and `Annotated`.
20
+ **No Magic. Just Python.**
20
21
 
21
- ## Highlights
22
+ Pytastic is a lightweight validation layer that respects your standard Python type hints. If you know `TypedDict` and `Annotated`, you already know how to use Pytastic.
23
+
24
+ ## Why?
22
25
  - **Zero Dependencies**: Pure Python standard library.
23
- - **Dual API**:
24
- - `vx.User(data)` for clean, dynamic usage.
25
- - `vx.validate(User, data)` for full IDE type safety.
26
- - **Rich Constraints**: `min`, `max`, `regex`, `unique`, `one_of`, `Literal`, and nested validation.
26
+ - **No Learning Curve**: It's just standard Python typing.
27
+ - **IDE Friendly**: We use standard types, so your IDE autocompletion works out of the box.
27
28
 
28
29
  ## Installation
29
30
 
@@ -45,20 +46,41 @@ class User(TypedDict):
45
46
  age: Annotated[int, "min=18"]
46
47
  role: Literal["admin", "user"]
47
48
 
48
- vx.register(User)
49
+ # 2. Usage Patterns
49
50
 
50
- # 2. Validate
51
+ ## Option A: Typed (Recommended)
52
+ **No registration required.** Best for IDE autocompletion.
53
+ ```python
51
54
  try:
52
- # Typed validation (IDE friendly)
53
55
  user = vx.validate(User, {"username": "tersoo", "age": 25, "role": "admin"})
54
56
  print(user)
55
-
56
- # 3. Export JSON Schema
57
- print(vx.schema(User))
58
57
  except Exception as e:
59
58
  print(e)
60
59
  ```
61
60
 
61
+ ## Option B: Dynamic (Requires Registration)
62
+ **Registration required.** Best for quick scripts or cleaner syntax.
63
+ ```python
64
+ vx.register(User)
65
+
66
+ # Now you can use the class name directly on the validator instance
67
+ user = vx.User({"username": "tersoo", "age": 25, "role": "admin"})
68
+ ```
69
+
70
+ ## 3. JSON Schema
71
+ ```python
72
+ # Export standard JSON Schema
73
+ print(vx.schema(User))
74
+ # Output:
75
+ # {
76
+ # "type": "object",
77
+ # "properties": {
78
+ # "username": { "type": "string", "minLength": 3 ... },
79
+ # ...
80
+ # }
81
+ # }
82
+ ```
83
+
62
84
  ## License
63
85
 
64
86
  MIT
@@ -0,0 +1,69 @@
1
+ # Pytastic
2
+
3
+ **No Magic. Just Python.**
4
+
5
+ Pytastic is a lightweight validation layer that respects your standard Python type hints. If you know `TypedDict` and `Annotated`, you already know how to use Pytastic.
6
+
7
+ ## Why?
8
+ - **Zero Dependencies**: Pure Python standard library.
9
+ - **No Learning Curve**: It's just standard Python typing.
10
+ - **IDE Friendly**: We use standard types, so your IDE autocompletion works out of the box.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install pytastic
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ from pytastic import Pytastic
22
+ from typing import TypedDict, Annotated, List, Literal
23
+
24
+ vx = Pytastic()
25
+
26
+ # 1. Define Schema
27
+ class User(TypedDict):
28
+ username: Annotated[str, "min_len=3; regex=^[a-z_]+$"]
29
+ age: Annotated[int, "min=18"]
30
+ role: Literal["admin", "user"]
31
+
32
+ # 2. Usage Patterns
33
+
34
+ ## Option A: Typed (Recommended)
35
+ **No registration required.** Best for IDE autocompletion.
36
+ ```python
37
+ try:
38
+ user = vx.validate(User, {"username": "tersoo", "age": 25, "role": "admin"})
39
+ print(user)
40
+ except Exception as e:
41
+ print(e)
42
+ ```
43
+
44
+ ## Option B: Dynamic (Requires Registration)
45
+ **Registration required.** Best for quick scripts or cleaner syntax.
46
+ ```python
47
+ vx.register(User)
48
+
49
+ # Now you can use the class name directly on the validator instance
50
+ user = vx.User({"username": "tersoo", "age": 25, "role": "admin"})
51
+ ```
52
+
53
+ ## 3. JSON Schema
54
+ ```python
55
+ # Export standard JSON Schema
56
+ print(vx.schema(User))
57
+ # Output:
58
+ # {
59
+ # "type": "object",
60
+ # "properties": {
61
+ # "username": { "type": "string", "minLength": 3 ... },
62
+ # ...
63
+ # }
64
+ # }
65
+ ```
66
+
67
+ ## License
68
+
69
+ MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pytastic"
3
- version = "0.0.1"
3
+ version = "0.0.3"
4
4
  description = "A dependency-free JSON validation library using TypedDict and Annotated"
5
5
  authors = ["Tersoo <tersoo@example.com>"]
6
6
  readme = "README.md"
pytastic-0.0.1/README.md DELETED
@@ -1,48 +0,0 @@
1
- # Pytastic
2
-
3
- A dependency-free, high-performance JSON validation library using Python's native `TypedDict` and `Annotated`.
4
-
5
- ## Highlights
6
- - **Zero Dependencies**: Pure Python standard library.
7
- - **Dual API**:
8
- - `vx.User(data)` for clean, dynamic usage.
9
- - `vx.validate(User, data)` for full IDE type safety.
10
- - **Rich Constraints**: `min`, `max`, `regex`, `unique`, `one_of`, `Literal`, and nested validation.
11
-
12
- ## Installation
13
-
14
- ```bash
15
- pip install pytastic
16
- ```
17
-
18
- ## Usage
19
-
20
- ```python
21
- from pytastic import Pytastic
22
- from typing import TypedDict, Annotated, List, Literal
23
-
24
- vx = Pytastic()
25
-
26
- # 1. Define Schema
27
- class User(TypedDict):
28
- username: Annotated[str, "min_len=3; regex=^[a-z_]+$"]
29
- age: Annotated[int, "min=18"]
30
- role: Literal["admin", "user"]
31
-
32
- vx.register(User)
33
-
34
- # 2. Validate
35
- try:
36
- # Typed validation (IDE friendly)
37
- user = vx.validate(User, {"username": "tersoo", "age": 25, "role": "admin"})
38
- print(user)
39
-
40
- # 3. Export JSON Schema
41
- print(vx.schema(User))
42
- except Exception as e:
43
- print(e)
44
- ```
45
-
46
- ## License
47
-
48
- MIT
File without changes
File without changes
File without changes
File without changes
File without changes