Jet\Form_ValidationError

The class represents a form field validation error.

Instance is convertible to string.

Finally, the error can be converted to JSON, so error messages can be easily sent in REST API responses.

Method Meaning of
public __construct(
Form_Field $field,
string $code,
string $message
)
Parameters:
  • $field
    The form field to which the error applies.
  • $code
    Error code.
  • $message
    Error messages - already translated and fully generated (complete with values).
public getField(
) : Form_Field
Returns the instance of the form field to which the error applies.
public getCode(
) : string
Returns an error code.
public getMessage(
) : string
Returns an error message - already translated and fully generated (complete with values).
public __toString(
) : string
The instance can be converted to a string. The result is an error message.
public toJSON(
) : string
The error can be converted to JSON format. The field will be represented by the field key and field name.
public jsonSerialize(
) : array
The error can be passed to the json_encode function.
Previous chapter
Jet\Form_Field
Next chapter
Types of form fields