-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move args validation to template helper
- Loading branch information
1 parent
529681c
commit 37fb10e
Showing
4 changed files
with
35 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { helper } from '@ember/component/helper'; | ||
import { assert } from '@ember/debug'; | ||
import { LinkArgs } from 'ember-link/components/link/component'; | ||
|
||
export function emberLinkValidateArgs([args]: [LinkArgs]): void { | ||
assert( | ||
`You provided '@queryParams', but the argument you mean is just '@query'.`, | ||
!('queryParams' in args) | ||
); | ||
assert( | ||
`You provided '@routeName', but the argument you mean is just '@route'.`, | ||
!('routeName' in args) | ||
); | ||
assert( | ||
`'@route' needs to be a valid route name.`, | ||
typeof args.route === 'string' | ||
); | ||
assert( | ||
`You cannot use both '@model' ('${args.model}') and '@models' ('${ | ||
args.models | ||
}') at the same time.`, | ||
!(args.model && args.models) | ||
); | ||
} | ||
|
||
export default helper(emberLinkValidateArgs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { | ||
default, | ||
emberLinkValidateArgs | ||
} from 'ember-link/helpers/ember-link/validate-args'; |