Created
December 11, 2013 15:33
-
-
Save holograph/7912483 to your computer and use it in GitHub Desktop.
A sample Accord validator execution (https://github.com/wix/accord).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val validPerson = Person( "Wernher", "von Braun" ) | |
validPerson: Person = Person(Wernher,von Braun) | |
scala> validate( validPerson ) | |
res0: com.wix.accord.Result = Success | |
scala> val invalidPerson = Person( "", "No First Name" ) | |
invalidPerson: Person = Person(,No First Name) | |
scala> validate( invalidPerson ) | |
res1: com.wix.accord.Result = Failure(List(RuleViolation(,must not be empty,firstName))) | |
scala> val explicitDescription = Person( "No Last Name", "" ) | |
explicitDescription: Person = Person(No Last Name,) | |
scala> validate( explicitDescription ) | |
res2: com.wix.accord.Result = Failure(List(RuleViolation(,must not be empty,last name))) | |
scala> val invalidClassroom = Classroom( Person( "Alfred", "Aho" ), Seq.empty ) | |
invalidClassroom: Classroom = Classroom(Person(Alfred,Aho),List()) | |
scala> validate( invalidClassroom ) | |
res3: com.wix.accord.Result = Failure(List(RuleViolation(List(),has size 0, expected more than 0,students))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment