-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
I've implemented a Regex - primitive parametrized type that matches regular expression on the string.
Should this be included as a basic type? or some sort of plugin/extension?
import re
from teleport import ValidationError, ParametrizedPrimitive, Schema
class Regex(ParametrizedPrimitive):
param_schema = Schema
def from_json(self, datum):
if re.match(self.param, datum) is None:
raise ValidationError("Regex '%s' does not match " % self.param, datum)
return datum
def to_json(self, datum):
return datumAlso, should I validate if datum is indeed a String?