Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.
v2 (legacy)errorMessageInterface

ErrorMessageInterface

The ErrorMessageInterface defines the structure of the error messages returned by the validation, ajax, etc. functions in the NFSFU234FormValidation Library.

ParameterTypeDefaultDescription
messagestring | boolean | numberundefinedThe error message which can be a string, boolean, or number.
typestringundefinedThe type of error.
codenumberundefinedThe error code.
datastring | number | object | Array<any> | JSON | HTMLElement | null | undefined | booleanundefinedAdditional data related to the error which can be of various types.

Usage

Example: Handling an Error Message using the Validate API function

const myForm = document.getElementById("myForm"); nfsfu234FormValidation.validate(myForm, (response) => { /** * Example of using the ErrorMessageInterface * * Here the response is in the ErrorMessageInterface formart so we destructure the ErrorMessageInterface * This enables us to to access its attributes and use them easily */ const { message, type, data, code } = response; console.log("Code: ", code); console.log("Message: ", message); console.log("Type: ", type); console.log("Data: ", data); });

See also

Last updated on