Skip to content

Commit

Permalink
make it look nice
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Dec 13, 2024
1 parent 2b0c813 commit 3490fb6
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions packages/atproto_client/models/string_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@


def only_validate_if_strict(validate_fn: Callable[..., str]) -> Callable[..., str]:
"""Skip pydantic validation if not opting into strict validation via context."""
"""Skips pydantic validation if not opting into strict validation via context."""

# Wrapper could be likely be generalized to support other signatures
@wraps(validate_fn)
Expand All @@ -77,7 +77,7 @@ def validate_handle(v: str) -> str:
- Last segment cannot start with a digit
Args:
v: The handle to validate (e.g. "alice.bsky.social")
v: The handle to validate (e.g. `alice.bsky.social`)
Returns:
str: The validated handle
Expand Down Expand Up @@ -107,11 +107,11 @@ def validate_did(v: str) -> str:
- Method must be lowercase letters
- Identifier allows alphanumeric chars, dots, underscores, hyphens, and percent
- Max 2KB length
- No /?#[]@ characters allowed
- No `/?#[]@` characters allowed
- Valid percent-encoding if used
Args:
v: The DID to validate (e.g. "did:plc:z72i7hdynmk6r22z27h6tvur")
v: The DID to validate (e.g. `did:plc:z72i7hdynmk6r22z27h6tvur`)
Returns:
str: The validated DID
Expand Down Expand Up @@ -147,11 +147,11 @@ def validate_nsid(v: str) -> str:
- Name segment (letters only)
- Max 317 chars total
- No segments ending in numbers
- No @_*#! special characters
- No `@_*#!` special characters
- Max 63 chars per segment
Args:
v: The NSID to validate (e.g. "app.bsky.feed.post")
v: The NSID to validate (e.g. `app.bsky.feed.post`)
Returns:
str: The validated NSID
Expand Down Expand Up @@ -181,7 +181,7 @@ def validate_language(v: str) -> str:
- Optional subtag with alphanumeric chars and hyphens
Args:
v: The language code to validate (e.g. "en" or "en-US")
v: The language code to validate (e.g. `en` or `en-US`)
Returns:
str: The validated language code
Expand All @@ -204,7 +204,7 @@ def validate_record_key(v: str) -> str:
- Not be "." or ".."
Args:
v: The record key to validate (e.g. "3jxtb5w2hkt2m")
v: The record key to validate (e.g. `3jxtb5w2hkt2m`)
Returns:
str: The validated record key
Expand All @@ -228,7 +228,7 @@ def validate_cid(v: str) -> str:
- Alphanumeric characters and plus signs only
Args:
v: The CID to validate
v: The CID to validate (e.g. `bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi`)
Returns:
str: The validated CID
Expand All @@ -246,14 +246,14 @@ def validate_at_uri(v: str) -> str:
"""Validate an AT Protocol URI.
Must follow pattern:
- Starts with "at://"
- Starts with `at://`
- Contains handle or DID
- Optional /collection/record-key path
- Optional `/collection/record-key` path
- Max 8KB length
- No query parameters or fragments
Args:
v: The AT-URI to validate (e.g. "at://alice.bsky.social/app.bsky.feed.post/3jxtb5w2hkt2m")
v: The AT-URI to validate (e.g. `at://alice.bsky.social/app.bsky.feed.post/3jxtb5w2hkt2m`)
Returns:
str: The validated AT-URI
Expand All @@ -275,15 +275,15 @@ def validate_datetime(v: str) -> str:
"""Validate an ISO 8601/RFC 3339 datetime string.
Requirements:
- Must use uppercase 'T' as time separator
- Must include seconds (HH:MM:SS)
- Must have timezone (Z or ±HH:MM)
- No -00:00 timezone allowed
- Must use uppercase `T` as time separator
- Must include seconds (`HH:MM:SS`)
- Must have timezone (`Z` or `±HH:MM`)
- No `-00:00` timezone allowed
- Valid fractional seconds format if used
- No whitespace allowed
Args:
v: The datetime string to validate (e.g. "2024-11-24T06:02:00Z")
v: The datetime string to validate (e.g. `2024-11-24T06:02:00Z`)
Returns:
str: The validated datetime string
Expand Down Expand Up @@ -332,7 +332,7 @@ def validate_tid(v: str) -> str:
- First byte's high bit (0x40) must be 0
Args:
v: The TID to validate (e.g. "3jxtb5w2hkt2m")
v: The TID to validate (e.g. `3jxtb5w2hkt2m`)
Returns:
str: The validated TID
Expand All @@ -357,7 +357,7 @@ def validate_uri(v: str) -> str:
- Must follow RFC-3986 format
Args:
v: The URI to validate (e.g. "https://example.com/path")
v: The URI to validate (e.g. `https://example.com/path`)
Returns:
str: The validated URI
Expand Down

0 comments on commit 3490fb6

Please sign in to comment.