Skip to content

Commit 6bd797b

Browse files
committed
add examples
1 parent 2ea05c2 commit 6bd797b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pydantic_extra_types/cron.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,24 @@ def next(self) -> datetime: ...
2323

2424

2525
class CronStr(str):
26-
"""A cron expression validated via [`cron-converter`](https://pypi.org/project/cron-converter/)."""
26+
"""A cron expression validated via [`cron-converter`](https://pypi.org/project/cron-converter/).
27+
## Examples
28+
```python
29+
from pydantic import BaseModel
30+
from pydantic_extra_types.cron import CronStr
31+
32+
class Schedule(BaseModel):
33+
cron: CronStr
34+
35+
schedule = Schedule(cron="*/5 * * * *")
36+
print(schedule.cron)
37+
>> */5 * * * *
38+
print(schedule.cron.minute)
39+
>> */5
40+
print(schedule.cron.next_run)
41+
>> 2025-10-07T22:40:00+00:00
42+
```
43+
"""
2744

2845
strip_whitespace: ClassVar[bool] = True
2946
"""Whether to strip surrounding whitespace from the input value."""

0 commit comments

Comments
 (0)