mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-18 06:42:51 +08:00

* WIP: add rbac authorization * Perform pre-commit fixes * add rbac route whitelist * add init test data user role associations * Restore database table id naming to fix generic crud base * Add database section value uniqueness settings * Update the test directory to tests * Update route_name file name to health_check * Split user auth and user action interfaces * Fix conflict between merge and current branch * Add pymysql dependencies * Fix RBAC authentication method * Add the select serialisation tool * Fix missing return messages due to global exception handler slicing * Update the user interface with associated relationships * Add items to be completed * Perform pre-commit fixes * Add pre-made routers * Paging data return structure optimisation * Split user auth and user interface tests * Fix user register test data structure error * Fix duplicate named test classes
44 lines
696 B
Python
44 lines
696 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import re
|
|
|
|
|
|
def search_string(pattern, text) -> bool:
|
|
"""
|
|
全字段正则匹配
|
|
|
|
:param pattern:
|
|
:param text:
|
|
:return:
|
|
"""
|
|
result = re.search(pattern, text)
|
|
if result:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def match_string(pattern, text) -> bool:
|
|
"""
|
|
从字段开头正则匹配
|
|
|
|
:param pattern:
|
|
:param text:
|
|
:return:
|
|
"""
|
|
result = re.match(pattern, text)
|
|
if result:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def is_phone(text: str) -> bool:
|
|
"""
|
|
检查手机号码
|
|
|
|
:param text:
|
|
:return:
|
|
"""
|
|
return match_string(r'^1[3-9]\d{9}$', text)
|