validate in model doesn't fail
while validates in model fail, you can still save the object, would be nicer if coudn’t be saved + returning null
Submitted on 2 March 2011 at 08:41
Issue Log
This sounds like a bug, can you give an example application where this problem occurs?
entity User {
name :: String (id, length = 50, validate(isUniqueUser(this), “Username is taken”), searchable)email :: Email (searchable) password :: Secret (validate(password.length() >= 8, "Password needs to be at least 8 characters") , validate(/[a-z]/.find(password), "Password must contain a lower-case character") , validate(/[A-Z]/.find(password), "Password must contain an upper-case character") , validate(/[0-9]/.find(password), "Password must contain a digit"))
}
init {
var niels := User {
name := “Niels Egberts”
email := “koobface@nielsegberts.nl”
password := (“wachtwoord” as Secret).digest()
};
}zou object niet mogen bestaan bestaat toch
ook in services zelfde soort probleem
This is actually pointing out a more general issue related to using entity validation with Secret types. In this example the validation will happen on the already digested password, which will be some hash function that usually contains lower- and upper-case characters, digits, and is long enough (but this could potentially fail).
The plan is to make the digest and check of Secret type automatic (related issue: https://yellowgrass.org/issue/WebDSL/45), and this example shows that validation should be disabled for already digested passwords (it would still work for new password inputs). The automatic digest would happen before persisting to the database, but after validation is performed.
Log in to post comments