saleor-dashboard/src/utils/errors.ts

12 lines
334 B
TypeScript
Raw Normal View History

2019-08-09 10:17:04 +00:00
import { UserError } from "@saleor/types";
2020-02-24 14:14:48 +00:00
export function getFieldError(errors: UserError[], field: string): UserError {
return errors.find(err => err.field === field);
2019-08-09 10:17:04 +00:00
}
export function getErrors(errors: UserError[]): string[] {
return errors
.filter(err => ["", null].includes(err.field))
.map(err => err.message);
}