Skip to content

Commit

Permalink
Adding enumproperty to simple type and edit openvocabproperty
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantxu1 committed Apr 4, 2024
1 parent eb4b2f1 commit 88f8ea3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions stix2/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def __init__(self, valid_types=None, spec_version=DEFAULT_VERSION, **kwargs):

simple_types = [
BinaryProperty, BooleanProperty, FloatProperty, HexProperty, IntegerProperty, StringProperty,
TimestampProperty, ReferenceProperty,
TimestampProperty, ReferenceProperty, EnumProperty
]
if not valid_types:
valid_types = [Property]
Expand Down Expand Up @@ -722,7 +722,11 @@ def __init__(self, allowed, **kwargs):
self.allowed = allowed
super(EnumProperty, self).__init__(**kwargs)

def clean(self, value, allow_custom):
def clean(self, value, allow_custom, strict=False):
if not isinstance(value, str):
if strict is True:
raise ValueError("Must be a string.")

cleaned_value, _ = super(EnumProperty, self).clean(value, allow_custom)

if cleaned_value not in self.allowed:
Expand All @@ -743,7 +747,7 @@ def __init__(self, allowed, **kwargs):
allowed = [allowed]
self.allowed = allowed

def clean(self, value, allow_custom):
def clean(self, value, allow_custom, strict=False):
cleaned_value, _ = super(OpenVocabProperty, self).clean(
value, allow_custom,
)
Expand Down

0 comments on commit 88f8ea3

Please sign in to comment.