Re: Validation for Ceylon

58 views
Skip to first unread message
Message has been deleted

Roland Tepp

unread,
Sep 27, 2017, 2:30:31 AM9/27/17
to ceylon-users
Hey Voitech,

This looks like a nice library.

Few nitpickings, if you don't mind.

First, just looking at your examples in the README, I noticed something un-Ceylonic in your code.

Exception? validateEndengered(AnimalSpecies species){
	if(species.isEndangered){
		return Exception("Animal is endangered");
	}
	return null;
}

You have properties like species.isEndangered — in Ceylon we don't generally prefix our boolean attributes with "is". That attribute should read like species.endangered instead.

Under the covers, it does translate to call to Java object's species.isEndangered() method and all shared attributes of a class defined in Ceylon have the appropriate Java Bean style accessor methods generated in JVM backend.

Secondly, perhaps the name `Exception` for a validation failure class is somewhat misleading. People generally expect Exceptions to be thrown, not returned ... 

Other than that, it seems good.

neljapäev, 14. september 2017 17:23.55 UTC+3 kirjutas Voitech:
Hello Guys, I made a generic validation library in Ceylon. I would ask if you could see if You are liking it. I called it Validx. You can find it in Ceylon Herd repo: https://herd.ceylon-lang.org/modules/herd.validx.core/1.0.0 , and code on github: https://github.com/voiii/ceylon-validx . All feedback would be appreciated regarding code, tutorial (on github in README.md), docs.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages