added validation of version value with convert_to_valid_type

This commit is contained in:
iLLiCiTiT 2021-12-08 17:27:02 +01:00
parent ccce04309b
commit 703368c5b0

View file

@ -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"]