Skip to content

Commit

Permalink
chore: turn api v1 utils into custom utils
Browse files Browse the repository at this point in the history
  • Loading branch information
vncsna committed Feb 20, 2024
1 parent b97883b commit dc95b84
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion bd_api/apps/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from ordered_model.models import OrderedModel

from bd_api.apps.account.models import Account
from bd_api.apps.api.v1.utils import check_kebab_case, check_snake_case
from bd_api.custom.model import BaseModel
from bd_api.custom.storage import OverwriteStorage, upload_to, validate_image
from bd_api.custom.utils import check_kebab_case, check_snake_case


def to_str(value: str | None, zfill: int = 0):
Expand Down
10 changes: 0 additions & 10 deletions bd_api/apps/api/v1/utils.py → bd_api/custom/utils.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# -*- coding: utf-8 -*-
"""
General-purpose functions for the API.
"""

import string


def check_snake_case(name: str) -> bool:
"""
Check if a string is in snake_case.
"""
allowed_chars = set(string.ascii_lowercase + string.digits + "_")
return set(name).issubset(allowed_chars) and name[0] != "_"


def check_kebab_case(name: str) -> bool:
"""
Check if a string is in kebab-case.
"""
allowed_chars = set(string.ascii_lowercase + string.digits + "-")
return set(name).issubset(allowed_chars) and name[0] != "-"

0 comments on commit dc95b84

Please sign in to comment.