#
# # Serializable book representation.
# class Book
-# super Jsonable
+# super Serializable
#
# # Book ISBN
# var isbn: String
# redef fun post(req, res) do
# var validator = new BookValidator
# if not validator.validate(req.body) then
-# res.json_error(validator.validation, 400)
+# res.json(validator.validation, 400)
# return
# end
# # TODO data persistence
#
# Errors messages are grouped into *scopes*. A scope is a string that specify wich
# field or document the error message is related to.
-#
-# See `HttpResponse::json_error`.
class ValidationResult
- super Jsonable
+ super Serializable
# Object parsed during validation
#
return validate_json(json)
end
- # Validate a Jsonable input
- fun validate_json(json: Jsonable): Bool do
+ # Validate a Serializable input
+ fun validate_json(json: Serializable): Bool do
if not json isa JsonObject then
validation.add_error("document", "Expected JsonObject got `{json.class_name}`")
return false
return validate_json(json)
end
- # Validate a Jsonable input
- fun validate_json(json: Jsonable): Bool do
+ # Validate a Serializable input
+ fun validate_json(json: Serializable): Bool do
if not json isa JsonArray then
validation.add_error("document", "Expected JsonArray got `{json.class_name}`")
return false