mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
added validation of version value with convert_to_valid_type
This commit is contained in:
parent
ccce04309b
commit
703368c5b0
1 changed files with 22 additions and 2 deletions
|
|
@ -2,10 +2,15 @@ from openpype.lib.openpype_version import (
|
|||
op_version_control_available,
|
||||
get_remote_versions,
|
||||
openpype_path_is_set,
|
||||
openpype_path_is_accessible
|
||||
openpype_path_is_accessible,
|
||||
get_OpenPypeVersion
|
||||
)
|
||||
from .input_entities import TextEntity
|
||||
from .lib import OverrideState
|
||||
from .lib import (
|
||||
OverrideState,
|
||||
NOT_SET
|
||||
)
|
||||
from .exceptions import BaseInvalidValue
|
||||
|
||||
|
||||
class OpenPypeVersionInput(TextEntity):
|
||||
|
|
@ -32,6 +37,21 @@ class OpenPypeVersionInput(TextEntity):
|
|||
state, *args, **kwargs
|
||||
)
|
||||
|
||||
def convert_to_valid_type(self, value):
|
||||
if value and value is not NOT_SET:
|
||||
OpenPypeVersion = get_OpenPypeVersion()
|
||||
if OpenPypeVersion is not None:
|
||||
try:
|
||||
OpenPypeVersion(version=value)
|
||||
except Exception:
|
||||
raise BaseInvalidValue(
|
||||
"Value \"{}\"is not valid version format.".format(
|
||||
value
|
||||
),
|
||||
self.path
|
||||
)
|
||||
return super(OpenPypeVersionInput, self).convert_to_valid_type(value)
|
||||
|
||||
|
||||
class ProductionVersionsInputEntity(OpenPypeVersionInput):
|
||||
schema_types = ["production-versions-text"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue