jpmckinney / validictory

🎓 deprecated general purpose python data validator
Other
240 stars 57 forks source link

support email format validator #51

Closed aconrad closed 11 years ago

aconrad commented 11 years ago

Before:

>>> import validictory
>>> validictory.validate("foo", {"type":"string", "format":"email"})
>>> 

After:

>>> import validictory
>>> validictory.validate("foo", {"type":"string", "format":"email"})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "validictory/__init__.py", line 31, in validate
    return v.validate(data, schema)
  File "validictory/validator.py", line 574, in validate
    self._validate(data, schema)
  File "validictory/validator.py", line 577, in _validate
    self.__validate("_data", {"_data": data}, schema)
  File "validictory/validator.py", line 608, in __validate
    newschema.get(schemaprop))
  File "validictory/validator.py", line 470, in validate_format
    format_validator(self, fieldname, value, format_option)
  File "validictory/validator.py", line 91, in validate_format_email
    "not an email" % locals(), fieldname, value)
validictory.validator.FieldValidationError: Value 'foo' of field '_data' is not an email
>>> 
jamesturk commented 11 years ago

this looks like a GPL'd regex, no?

aconrad commented 11 years ago

Yes, it looks like it. I'm no lawyer, would this not work with the validictory MIT-like licence?

paultag commented 11 years ago

@aconrad - it would, but the resulting combined work (The GPL calls this a Modified work, as defined in section 0) - section 5 (Conveying Modified Source Versions) subsection c dicatates: "You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged."

This would result in the entire library being distributed under the GPL, since it'd be conveyed as single work.

Basically, yes, but it'd mean the project would turn into a GPL licensed project, which might not be what @jamesturk would like -- it's easier if we find something matching the license of validictory

aconrad commented 11 years ago

Make sense, thanks @paultag. The plumbing is in place to validate emails, I'll come up with another validator, there are plenty out there (but this one seemed to be the most complete and accurate at the time).

paultag commented 11 years ago

NP; thanks for the hack, @aconrad !

aconrad commented 11 years ago

Replaced with one from http://www.regular-expressions.info/email.html but I couldn't find any information about licensing...

ldave commented 11 years ago

why isn't this merged yet?

jamesturk commented 11 years ago

due to licensing concerns & this http://davidcel.is/blog/2012/09/06/stop-validating-email-addresses-with-regex/

it's easy enough for people to add an email validator in their own code if that's what they want, I'd prefer not support this mostly-bad practice from within validictory