breeze-client / ValidationError
Class: ValidationError
Defined in: src/validation/validate.ts:975
Describes one failed validation: which validator failed, on which property, and the message to show. An entity's current errors are in EntityAspect.getValidationErrors. The errors a server reports for a failed save are added there too, with ValidationError.isServerError set.
Constructors
Constructor
new ValidationError(
validator,context,errorMessage,key?):ValidationError
Defined in: src/validation/validate.ts:1002
Creates a validation error. Applications usually add one with EntityAspect.addValidationError after creating it here.
Parameters
validator
Validator | null
The Validator that found the error, or null for an error found some other way.
context
The context to record with the error: for a property, its entity, property, propertyName and value.
errorMessage
string
The message to show.
key?
string
Identifies the error among the entity's errors. If not given, it is built from the validator's name - or, without a validator, the error message - and the property name; see ValidationError.getKey.
Returns
ValidationError
Properties
context
context:
any
Defined in: src/validation/validate.ts:981
The context the error was created with - for a validator, its context when it ran, which for a property error includes entity, property, propertyName and value. Read Only
errorMessage
errorMessage:
string
Defined in: src/validation/validate.ts:983
The error message. Read Only
isServerError
isServerError:
boolean
Defined in: src/validation/validate.ts:989
Whether this error came from the server in a failed save. Server errors do not block a save, and are cleared when the property is changed or the entity is saved again. Read Only
key
key:
string
Defined in: src/validation/validate.ts:979
The key that identifies this error among an entity's validation errors: the validator's name (or the error name), then : and the property name if there is one. Adding an error with the same key replaces the old one. Read Only
property
property:
any
Defined in: src/validation/validate.ts:985
The DataProperty or NavigationProperty this error is about, or undefined for an entity-level error. Read Only
propertyName?
optionalpropertyName?:string
Defined in: src/validation/validate.ts:987
The name of the property this error is about - a property path, such as address.city, for a property of a complex object - or undefined for an entity-level error. Read Only
validator?
optionalvalidator?:Validator
Defined in: src/validation/validate.ts:977
The Validator that produced this error. undefined for an error from the server or one created without a validator. Read Only
Methods
getKey()
staticgetKey(validatorOrErrorName,propertyName?):string
Defined in: src/validation/validate.ts:1029
Composes a ValidationError 'key' given a validator or an errorName and an optional propertyName
Parameters
validatorOrErrorName
string | Validator
A Validator, or an "error name" if no validator is available.
propertyName?
string
A property name
Returns
string
A ValidationError 'key'