Skip to content

Commit

Permalink
PublicErrors type (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer authored Jan 17, 2020
1 parent 2d84507 commit 5b5d8b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions addon/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export type Errors<T> = {
[s: string]: IErr<T>
};

export type PublicErrors = { key: string; value: any; validation: ValidationErr | ValidationErr[] }[];

export type RunningValidations = {
[s: string]: number
};
Expand Down Expand Up @@ -70,8 +72,8 @@ export interface ChangesetDef {
_runningValidations: RunningValidations,
_bareChanges: { [s: string]: any },

changes: object[],
errors: object[],
changes: Record<string, any>[],
errors: PublicErrors,
error: object,
change: object,
data: object,
Expand Down
7 changes: 5 additions & 2 deletions addon/utils/get-key-values.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import isObject from './is-object';
import Err from '../-private/err';
import {
PublicErrors
} from 'ember-changeset/types';

let keysUpToValue: string[] = [];

Expand All @@ -9,7 +12,7 @@ let keysUpToValue: string[] = [];
* @method getKeyValues
* @return {Array} [{ 'person.name': value }]
*/
export function getKeyValues<T extends Record<string, any>>(obj: T): object[] {
export function getKeyValues<T extends Record<string, any>>(obj: T): Record<string, any>[] {
let map = [];

for (let key in obj) {
Expand Down Expand Up @@ -38,7 +41,7 @@ let errorKeysUpToValue: string[] = [];
* @method getKeyErrorValues
* @return {Array} [{ key: 'person.name', validation: '', value: '' }]
*/
export function getKeyErrorValues<T extends Record<string, any>>(obj: T): object[] {
export function getKeyErrorValues<T extends Record<string, any>>(obj: T): PublicErrors {
let map = [];

for (let key in obj) {
Expand Down

0 comments on commit 5b5d8b8

Please sign in to comment.