Replace konstraint extensions by a validator Kotlin DSL
See original GitHub issueIn order to provide a more idiomatic Kotlin experience, I am wondering if we could replace konstraint
extensions introduced by #16 (I don’t really like this kind of k
prefixed to be honest) by a Kotlin DSL that would isolate more the Kotlin API from the Java one. I need to give it more thoughts but my initial proposal is the following:
val validator = validator<User> {
constraint(User::name) {
notNull()
lessThanOrEqual(20)
}
constraint(User::email) {
notNull()
greaterThanOrEqual(5)
lessThanOrEqual(50) //
email()
}
constraint(User::age) {
notNull()
greaterThanOrEqual(0)
lessThanOrEqual(200)
}
}
Any thoughts? If you like it I can probably try to craft a PR.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:8 (6 by maintainers)
Top Results From Across the Web
YAVI (Yet Another ValIdation) Reference Documentation
The ValidatorBuilder#constraint is used to declare the constraints which should ... If you are using Kotlin, you can define a Validator with DSL...
Read more >Chapter 11. DSL construction - Kotlin in Action
In this chapter, we'll discuss how you can design expressive and idiomatic APIs for your Kotlin classes through the use of domain-specific languages...
Read more >Validation with Hibernate Validator - Quarkus
This command generates a Maven structure importing the RESTEasy Reactive/JAX-RS, Jackson and Hibernate Validator/Bean Validation extensions.
Read more >Object validation in Ktor/Kotlin. Introduction | Nerd For Tech
The API is fluent but it doesn't have a DSL: Overall the API looked out-dated and it's also dependent on some Android specific...
Read more >[HV-1796] Kotlin extension function on parameterized type ...
Method constraints validation. Kotlin. Presence of extension ... Given the following code making use of method constraint validation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
let me try to make time! (might not be within the next 2 weeks)
Supported by 0329aa47f67c4071adc3cc576f9287faaddbdde7 🎉