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

On 2 March 2011 at 12:00 Danny Groenewegen commented:

This sounds like a bug, can you give an example application where this problem occurs?

On 2 March 2011 at 22:16 chris melman commented:

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

On 3 March 2011 at 14:40 Danny Groenewegen commented:

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.

On 26 November 2013 at 15:24 Elmer van Chastelet tagged validation

Log in to post comments