Open rboixaderg opened 3 years ago
You can use this in the meantime:
@implementer(ITextLine)
class RegexField(schema.TextLine):
def __init__(self, *args, regex, **kwargs):
super().__init__(*args, **kwargs)
self.regex = re.compile(regex)
def _validate(self, value):
super()._validate(value)
if not self.regex.match(value):
raise InvalidValue(value, self.__name__)
rgba_color = RegexField(regex=r"^#[0-9A-Fa-f]{6,8}$")
I can open a PR as well if we want this in Guillotina.
Add regex field in guillotina schema