Skip to content

Instantly share code, notes, and snippets.

@1gravity
Created April 7, 2021 18:07
Show Gist options
  • Save 1gravity/d9bbc8f563b894de4d8868f46b506a23 to your computer and use it in GitHub Desktop.
Save 1gravity/d9bbc8f563b894de4d8868f46b506a23 to your computer and use it in GitHub Desktop.
val spec = validationSpec(messageBundle = "MyMessages", locale = Locale.FRENCH) {
constraints<MyClass> {
property(MyClass::color) {
notBlank()
inValues("GREEN", "WHITE", "RED")
size(3, 5)
}
property(MyClass::token) {
regexp("[A-Za-z0-9]+")
}
property(MyClass::date) {
future()
}
returnOf(Foo::validate) {
assertTrue()
}
property(MyClass::innerClass) {
valid()
}
}
constraints<InnerClass> {
property(InnerClass::amount) {
negativeOrZero()
}
property(InnerClass::emailList) {
notEmpty()
eachElement {
notNull()
email()
}
}
}
}
@1gravity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment