Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 4cd263c

Browse files
committed
Change path to field
1 parent 9603d32 commit 4cd263c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ This package changes the `message` to be an object with field names as keys:
2222
"error": "Bad Request",
2323
"message": [
2424
{
25-
"path": "email",
25+
"field": "email",
2626
"errors": ["email must be an email"]
2727
},
2828
{
29-
"path": "phone",
29+
"field": "phone",
3030
"errors": ["phone should not be empty"]
3131
}
3232
]
@@ -37,7 +37,7 @@ It also works with [nested validations](https://github.com/typestack/class-valid
3737

3838
```json
3939
{
40-
"path": "nestedObject.name",
40+
"field": "nestedObject.name",
4141
"errors": ["name should not be empty"]
4242
}
4343
```

src/validation.pipe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class ValidationPipe extends OriginalValidationPipe {
1212
.filter(item => !!item.constraints)
1313
.map(item => ({
1414
errors: Object.values(item.constraints || {}),
15-
path: (item as any).path || item.property,
15+
field: (item as any).field || item.property,
1616
}))
1717
.filter(errorObject => errorObject.errors.length > 0)
1818
.flatten()
@@ -24,7 +24,7 @@ export class ValidationPipe extends OriginalValidationPipe {
2424
error: ValidationError
2525
): ValidationError {
2626
return ({
27-
path: `${parentPath}.${error.property}`,
27+
field: `${parentPath}.${error.property}`,
2828
...super.prependConstraintsWithParentProp(parentPath, error),
2929
} as unknown) as ValidationError;
3030
}

0 commit comments

Comments
 (0)