Getting there
This commit is contained in:
@@ -19,7 +19,7 @@ class LocalFlightStatus(str, Enum):
|
||||
|
||||
class LocalFlightBase(BaseModel):
|
||||
registration: str
|
||||
type: str # Aircraft type
|
||||
type: Optional[str] = None # Aircraft type - optional, can be looked up later
|
||||
callsign: Optional[str] = None
|
||||
pob: int
|
||||
flight_type: LocalFlightType
|
||||
@@ -31,11 +31,13 @@ class LocalFlightBase(BaseModel):
|
||||
raise ValueError('Aircraft registration is required')
|
||||
return v.strip().upper()
|
||||
|
||||
@validator('type')
|
||||
@validator('type', pre=True, always=False)
|
||||
def validate_type(cls, v):
|
||||
if not v or len(v.strip()) == 0:
|
||||
raise ValueError('Aircraft type is required')
|
||||
return v.strip()
|
||||
if v is None or (isinstance(v, str) and len(v.strip()) == 0):
|
||||
return None
|
||||
if isinstance(v, str):
|
||||
return v.strip()
|
||||
return v
|
||||
|
||||
@validator('pob')
|
||||
def validate_pob(cls, v):
|
||||
|
||||
Reference in New Issue
Block a user