Home Intro Source Mebo GitHub
import ValidationFail from 'mebo/src/MeboErrors/ValidationFail.js'
public class | source

ValidationFail

Extends:

ErrorMeboError → ValidationFail

Exception raised by Input validations.

It carries additional information about the context of the error that can be used when reporting/handling it. For this reason when this exception handled by a Handler it gets encoded into json ValidationFail.toJSON.

throw new ValidationFail('File does not exit!')

See:

Static Method Summary

Static Public Methods
public static

Creates a ValidationFail instance based on the input json string

Constructor Summary

Public Constructor
public

constructor(message: string, code: string, inputName: string)

Initialize the exception

Member Summary

Public Members
public set

code(errorCode: string): *

Sets an unique error code specifically related with that has failed validation, this information can be used later to identify the origin of the error, instead of trying to parse the message to figure out that information.

public get

Returns the code related with the validation itself

public

Boolean telling if this error is not allowed as output (Handler.output) when it has been raised from a nested action (an action created from another action (Action.createAction)).

public set

inputName(inputName: string): *

Sets the input name related with the validation

public get

Returns the input name related with the validation

public

Status code used by the Handler when this error is raised from inside of a top level action (an action that has not been created from another action).

Method Summary

Public Methods
public

Bakes the exception into a json string

Inherited Summary

From class MeboError
public

Boolean telling if this error is not allowed as output (Handler.output) when it has been raised from a nested action (an action created from another action (Action.createAction)).

public

Status code used by the Handler when this error is raised from inside of a top level action (an action that has not been created from another action).

Static Public Methods

public static fromJSON(json: string): ValidationFail source

Creates a ValidationFail instance based on the input json string

Params:

NameTypeAttributeDescription
json string

string containing the serialized json version of the exception

Return:

ValidationFail

Public Constructors

public constructor(message: string, code: string, inputName: string) source

Initialize the exception

Params:

NameTypeAttributeDescription
message string

error message

code string
  • optional

unique code based on uuid v4 that can be used to identify the error

inputName string
  • optional

name of the input about where the exception was generated type

Public Members

public set code(errorCode: string): * source

Sets an unique error code specifically related with that has failed validation, this information can be used later to identify the origin of the error, instead of trying to parse the message to figure out that information.

public get code: string source

Returns the code related with the validation itself

public disableOutputInNested: boolean source

Boolean telling if this error is not allowed as output (Handler.output) when it has been raised from a nested action (an action created from another action (Action.createAction)). When output is disabled the error will not be handled by the Writer, therefore the error will be emitted by the signal Handler.onErrorDuringOutput.

Value driven by: Settings.get('error/validationFail/disableOutputInNested') (default: true)

Override:

MeboError#disableOutputInNested

public set inputName(inputName: string): * source

Sets the input name related with the validation

public get inputName: string source

Returns the input name related with the validation

public status: number source

Status code used by the Handler when this error is raised from inside of a top level action (an action that has not been created from another action).

Value driven by: Settings.get('error/validationFail/status') (default: 400)

Override:

MeboError#status

Public Methods

public toJSON(): string source

Bakes the exception into a json string

Return:

string

json string containing the serialized version of the exception