Skip to content

Commit

Permalink
Allow for optional children validators
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerac4 committed Jan 10, 2023
1 parent 615d358 commit 0e90249
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ember-validations/src/components/form-validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FormValidatorChild from './child';

interface FormValidatorArgs<C extends GenericChangeset<V>, V = ValueForChangeset<C>> {
changeset: C;
submit: (changesets: [C, GenericChangeset<any>[]]) => void;
submit: (changesets: [C, GenericChangeset<any>[]] | [C]) => void;
}

export type BoundInputValidator<C extends GenericChangeset<V>, V = ValueForChangeset<C>> = WithBoundArgs<
Expand Down
16 changes: 15 additions & 1 deletion test-app/app/controllers/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ export default class ApplicationController extends Controller {
declare model: RouteModel<Application>;
declare childChangeset: GenericChangeset<{ foo: string }>;
@action
submitForm() {
submitForm([parent, children]: [
GenericChangeset<{
name: null;
num: string;
radio: null;
nestedItem: {
much: {
wow: null;
};
};
}>,
[GenericChangeset<{ foo: string }>]
]) {
parent.name;
children[0].foo;
window.alert('submitted succesfully!');
}

Expand Down

0 comments on commit 0e90249

Please sign in to comment.