Esempio n. 1
0
 def validate(self, attrs):
     if attrs["input"] == attrs["output"]:
         raise serializers.ValidationError("Invalid io mode")
     for item in (attrs["input"], attrs["output"]):
         if not re.match("^[a-zA-Z0-9.]+$", item):
             raise serializers.ValidationError("Invalid io file name format")
     return attrs
Esempio n. 2
0
 def validate(self, data):
     input_data = data
     data["username"] = data["username"].lower()
     data["email"] = data["email"].lower()
     if User.objects.filter(username=data["username"]).exists():
         raise serializers.ValidationError("Username already exists")
     if User.objects.filter(email=data["email"]).exists():
         raise serializers.ValidationError("Email already exists")
     return input_data