
errors._errors.gson Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nucleus Show documentation
Show all versions of nucleus Show documentation
nucleus is a Grails-Groovy plugin which contains utility methods, classes and endpoints.
import org.springframework.validation.*
/**
* Renders validation errors according to vnd.error: https://github.com/blongden/vnd.error
*/
model {
Errors errors
}
response.status UNPROCESSABLE_ENTITY
json {
Errors errorsObject = (Errors)this.errors
def allErrors = errorsObject.allErrors
int errorCount = allErrors.size()
def resourcePath = g.link(resource:request.uri, absolute:false)
def resourceLink = g.link(resource:request.uri, absolute:true)
if(errorCount == 1) {
def error = allErrors.iterator().next()
message messageSource.getMessage(error, locale)
path resourcePath
_links {
self {
href resourceLink
}
}
}
else {
total errorCount
_embedded {
errors(allErrors) { ObjectError error ->
message messageSource.getMessage(error, locale)
path resourcePath
_links {
self {
href resourceLink
}
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy