Utilities

Core utilities

Utilities which are of partcular interest when inplementing your own form components are exposed on the forms namespace object.

class ErrorObject(errors)
ErrorObject.set()
ErrorObject.get()
ErrorObject.isPopulated()
ErrorObject.asUL()
ErrorObject.asText()
ErrorObject.defaultRendering()
ErrorObject.toString()
class ErrorList(errors)
ErrorList.extend()
ErrorList.isPopulated()
ErrorList.asUL()
ErrorList.asText()
ErrorList.defaultRendering()
ErrorList.toString()
class ValidationError(message, {code: null, params: null})

Thrown by validation methods to indicate that invalid data was detected. The message argument can be a list of strings or a string, in which case an error code and a message parameters object can be provided to enable customisation of the resulting error message based on the code.

This constructor is actually provided by the validators package, but is exposed as part of newforms’ exports for convenience.

formData(form)

Creates an object representation of a form’s contents.