Is there a simple way to handle a post request val...
# ktor
a
Is there a simple way to handle a post request validation in ktor?
d
Do you mean validate a form?
using regex, lengths and so on?
a
Yes to validate a form. Make sure the json sent is valid and if not throw an exception
d
What about something like:
Copy code
class MyForm(val name: String, val age: Int) {
	init {
		check(name.size in 2 until 50)
		check(age in 0 until 150)
	}
}
👍 1
❤️ 1
and just deserialize that class?
a
Sounds good. Thanks @Deactivated User ill try that and get back to you
e
👍 1
a
Bean validation also sounds good but i need to use hibernate for that right?
Thanks again @Deactivated User your approach is simple enough. Ill just make my own check function or maybe an annotation with some restrictions and throw a custom "ValidationException" or something if its false
👍 1