Merge: Popcorn: more validators
authorJean Privat <jean@pryen.org>
Wed, 17 May 2017 13:53:39 +0000 (09:53 -0400)
committerJean Privat <jean@pryen.org>
Wed, 17 May 2017 13:53:39 +0000 (09:53 -0400)
Add two more validators:
* URLField that ensures a field contains a valid URL (you want to redefine that regexp).
* UniqField stubs for uniq emails, logins, ids validation.

How to validate uniq field:

~~~nit
class UniqEmailField
super UniqField

var users: UsersRepository

redef fun check_unicity(v, field, val) do
var user = users.find_by_email(val)
if user != null then
v.validation.add_error(field, "Email `{val}` already used")
return false
end
return true
end
end
~~~

Pull-Request: #2435

1  2 
lib/popcorn/pop_validation.nit

Simple merge