|
|
@ -11,10 +11,10 @@ import { getControlPath } from './forms-helper'; |
|
|
|
|
|
|
|
|
export class ErrorValidator { |
|
|
export class ErrorValidator { |
|
|
private errorsCache: { [path: string]: { value: any } } = {}; |
|
|
private errorsCache: { [path: string]: { value: any } } = {}; |
|
|
private error: ErrorDto | undefined | null; |
|
|
private errorSource: ErrorDto | undefined | null; |
|
|
|
|
|
|
|
|
public validator: ValidatorFn = control => { |
|
|
public validator: ValidatorFn = control => { |
|
|
if (!this.error) { |
|
|
if (!this.errorSource) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -35,8 +35,8 @@ export class ErrorValidator { |
|
|
|
|
|
|
|
|
const errors: string[] = []; |
|
|
const errors: string[] = []; |
|
|
|
|
|
|
|
|
if (this.error.details) { |
|
|
if (this.errorSource.details) { |
|
|
for (const details of this.error.details) { |
|
|
for (const details of this.errorSource.details) { |
|
|
for (const property of details.properties) { |
|
|
for (const property of details.properties) { |
|
|
if (property.startsWith(path)) { |
|
|
if (property.startsWith(path)) { |
|
|
const subProperty = property.substring(path.length); |
|
|
const subProperty = property.substring(path.length); |
|
|
@ -73,6 +73,6 @@ export class ErrorValidator { |
|
|
|
|
|
|
|
|
public setError(error: ErrorDto | undefined | null) { |
|
|
public setError(error: ErrorDto | undefined | null) { |
|
|
this.errorsCache = {}; |
|
|
this.errorsCache = {}; |
|
|
this.error = error; |
|
|
this.errorSource = error; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|