31 import java.util.* |
31 import java.util.* |
32 import javax.servlet.http.HttpServletRequest |
32 import javax.servlet.http.HttpServletRequest |
33 import javax.servlet.http.HttpServletResponse |
33 import javax.servlet.http.HttpServletResponse |
34 import javax.servlet.http.HttpSession |
34 import javax.servlet.http.HttpSession |
35 import kotlin.math.min |
35 import kotlin.math.min |
|
36 import java.sql.Date as SqlDate |
36 |
37 |
37 typealias MappingMethod = (HttpRequest, DataAccessObject) -> Unit |
38 typealias MappingMethod = (HttpRequest, DataAccessObject) -> Unit |
38 typealias PathParameters = Map<String, String> |
39 typealias PathParameters = Map<String, String> |
39 |
40 |
40 sealed interface ValidationResult<T> |
41 sealed interface ValidationResult<T> |
287 nodePatterns = parse(pattern) |
288 nodePatterns = parse(pattern) |
288 collection = pattern.endsWith("/") |
289 collection = pattern.endsWith("/") |
289 } |
290 } |
290 } |
291 } |
291 |
292 |
|
293 // <editor-fold desc="Validators"> |
|
294 |
|
295 fun dateOptValidator(input: String?): ValidationResult<SqlDate?> { |
|
296 return if (input.isNullOrBlank()) { |
|
297 ValidatedValue(null) |
|
298 } else { |
|
299 try { |
|
300 ValidatedValue(SqlDate.valueOf(input)) |
|
301 } catch (ignored: IllegalArgumentException) { |
|
302 ValidationError("validation.date.format") |
|
303 } |
|
304 } |
|
305 } |
|
306 |
|
307 // </editor-fold> |