# 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
end
validation.array = json
var allow_empty = self.allow_empty
if json.is_empty and (allow_empty != null and not allow_empty) then
validation.add_error("document", "Cannot be empty")
return false
end
var length = self.length
if length != null and json.length != length then
validation.add_error("document", "Array length must be exactly `{length}`")
return false
end
return true
end
lib/popcorn/pop_validation.nit:248,2--267,4