Skip to content

Commit

Permalink
well_trajectory: use more robust validator
Browse files Browse the repository at this point in the history
  • Loading branch information
verveerpj committed Aug 15, 2024
1 parent 7c87ad9 commit 55dcc83
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/everest_models/jobs/fm_well_trajectory/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
FilePath,
PlainSerializer,
StringConstraints,
ValidationInfo,
field_validator,
model_validator,
)
from typing_extensions import Annotated
Expand Down Expand Up @@ -400,14 +398,12 @@ class ConfigSchema(ModelConfig):
),
]

@field_validator("wells")
def _validate_wells(
cls, wells: Tuple[WellConfig, ...], values: ValidationInfo
) -> Tuple[WellConfig, ...]:
for well in wells:
_platforms = [item.name for item in values.data["platforms"]]
@model_validator(mode="after")
def _validate_wells(self) -> ConfigSchema:
_platforms = [item.name for item in self.platforms]
for well in self.wells:
if well.platform is not None and well.platform not in _platforms:
raise ValueError(
f"Platform '{well.platform}' for well '{well.name}' not defined"
)
return wells
return self

0 comments on commit 55dcc83

Please sign in to comment.