cozy

  • 홈
  • 태그
  • 방명록

Pydantic 1

[FastAPI] Pydantic validator의 재사용

Validator pydantic의 BaseModel을 사용하여 프론트에서 받을 Body 값을 지정하는 동시에 Body 값 중에 validator가 필요한 경우 pydantic model 안에서 정의할 수 있다. 아래의 예시는 pydantic 공식 페이지에서 제공하는 예시와 설명이다. from pydantic import BaseModel, ValidationError, validator class UserModel(BaseModel): name: str username: str password1: str password2: str @validator('name') def name_must_contain_space(cls, v): if ' ' not in v: raise ValueError('must c..

FastAPI 2023.04.21
이전
1
다음
더보기
프로필사진

cozy

  • 분류 전체보기
    • Python
    • Django
    • FastAPI
    • Docker
    • Database

Tag

믹스패널, wecode, Pydantic, Django 초기 세팅, set_cookie, Python, nested function, django, token authentication, Til, 일급객체, delete_cookie, List comprehensions, API Testing, corsheaders, FastAPI, refactoring, Mixpanel, first class citizen, drf,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2026/01   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

방문자수Total

  • Today :
  • Yesterday :

Copyright © AXZ Corp. All rights reserved.

티스토리툴바