Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: extends validation error and validation error items explanation #13815

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 17 additions & 5 deletions lib/errors/validation-error.ts
Expand Up @@ -34,8 +34,18 @@ export enum ValidationErrorItemOrigin {
}

/**
* Validation Error Item
* Instances of this class are included in the `ValidationError.errors` property.
*
* | parameter | description |
fzn0x marked this conversation as resolved.
Show resolved Hide resolved
* | --- | --- |
* | message | An error message |
* | type | The type/origin of the validation error |
* | path | The field that triggered the validation error |
* | value | The value that generated the error |
* | instance | the DAO instance that caused the validation error |
* | validatorKey |a validation "key", used for identification |
* | fnName | property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable |
* | fnArgs | parameters used with the BUILT-IN validator function, if applicable |
*/
export class ValidationErrorItem {
/**
Expand Down Expand Up @@ -195,11 +205,13 @@ export class ValidationErrorItem {
}

/**
* Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors` property,
* which is an array with 1 or more ValidationErrorItems, one for each validation that failed.
* Thrown when the sequelize validation has failed. The error contains an `errors` property,
* which is an array with 1 or more [ValidationErrorItem](/esdoc/class/lib/errors/validation-error.ts~ValidationErrorItem.html), one for each validation that failed.
fzn0x marked this conversation as resolved.
Show resolved Hide resolved
*
* @param message Error message
* @param errors Array of ValidationErrorItem objects describing the validation errors
* | parameter | description |
fzn0x marked this conversation as resolved.
Show resolved Hide resolved
* | --- | --- |
* | message | An error message |
* | errors | An array of ValidationErrorItem objects describing the validation errors |
*/
class ValidationError extends BaseError {
errors: ValidationErrorItem[];
Expand Down
6 changes: 4 additions & 2 deletions types/lib/errors.d.ts
Expand Up @@ -17,7 +17,7 @@ export class ValidationError extends BaseError {
public readonly errors: ValidationErrorItem[];

/**
* Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors`
* Thrown when the sequelize validation has failed. The error contains an `errors`
* property, which is an array with 1 or more ValidationErrorItems, one for each validation that failed.
*
* @param message Error message
Expand All @@ -28,7 +28,9 @@ export class ValidationError extends BaseError {
/**
* Gets all validation error items for the path / field specified.
*
* @param path The path to be checked for error items
* @param {string} path The path to be checked for error items
*
* @returns {Array<ValidationErrorItem>} Validation error items for the specified path
*/
public get(path: string): ValidationErrorItem[];
}
Expand Down