-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export hasValidations decorator for es6 style models (#583)
* export hasValidations decorator for es6 style models update docs * update node level * don’t require ember-beta to succeed * streamline test
- Loading branch information
1 parent
e7616ed
commit 580cced
Showing
11 changed files
with
168 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
ecmaVersion: 2017, | ||
sourceType: 'module' | ||
|
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
Empty file.
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,22 @@ | ||
/** | ||
* Decorator that allows you to mixin validations when using es6 style model classes | ||
* | ||
* Usage: | ||
* | ||
* import { hasValidations } from 'ember-cp-validations'; | ||
* | ||
* @hasValidations(Validations) | ||
* export default class YourModel extends Model { | ||
* @attr('string') name | ||
* }; | ||
* | ||
* | ||
* @param validations | ||
* @returns {decorator} | ||
*/ | ||
|
||
export function hasValidations(validations) { | ||
return function decorator(target) { | ||
target.prototype.reopen(validations); | ||
}; | ||
} |
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
Empty file.
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,16 @@ | ||
import Model from 'ember-data/model'; | ||
import { attr } from 'ember-decorators/data'; | ||
import { | ||
hasValidations, | ||
validator, | ||
buildValidations | ||
} from 'ember-cp-validations'; | ||
|
||
const Validations = buildValidations({ | ||
name: validator('presence', { presence: true, description: 'Name' }) | ||
}); | ||
|
||
@hasValidations(Validations) | ||
export default class Company extends Model { | ||
@attr('string') name; | ||
} |
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 |
---|---|---|
|
@@ -8,6 +8,12 @@ | |
dependencies: | ||
"@babel/highlight" "7.0.0-beta.42" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9" | ||
dependencies: | ||
"@babel/highlight" "7.0.0-beta.44" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0-beta.42.tgz#777bb50f39c94a7e57f73202d833141f8159af33" | ||
|
@@ -18,6 +24,16 @@ | |
source-map "^0.5.0" | ||
trim-right "^1.0.1" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0-beta.44.tgz#c7e67b9b5284afcf69b309b50d7d37f3e5033d42" | ||
dependencies: | ||
"@babel/types" "7.0.0-beta.44" | ||
jsesc "^2.5.1" | ||
lodash "^4.2.0" | ||
source-map "^0.5.0" | ||
trim-right "^1.0.1" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.42.tgz#b38b8f4f85168d1812c543dd700b5d549b0c4658" | ||
|
@@ -26,18 +42,38 @@ | |
"@babel/template" "7.0.0-beta.42" | ||
"@babel/types" "7.0.0-beta.42" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz#e18552aaae2231100a6e485e03854bc3532d44dd" | ||
dependencies: | ||
"@babel/helper-get-function-arity" "7.0.0-beta.44" | ||
"@babel/template" "7.0.0-beta.44" | ||
"@babel/types" "7.0.0-beta.44" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.42.tgz#ad072e32f912c033053fc80478169aeadc22191e" | ||
dependencies: | ||
"@babel/types" "7.0.0-beta.42" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz#d03ca6dd2b9f7b0b1e6b32c56c72836140db3a15" | ||
dependencies: | ||
"@babel/types" "7.0.0-beta.44" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.42.tgz#0d0d5254220a9cc4e7e226240306b939dc210ee7" | ||
dependencies: | ||
"@babel/types" "7.0.0-beta.42" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz#c0b351735e0fbcb3822c8ad8db4e583b05ebd9dc" | ||
dependencies: | ||
"@babel/types" "7.0.0-beta.44" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.42.tgz#a502a1c0d6f99b2b0e81d468a1b0c0e81e3f3623" | ||
|
@@ -46,6 +82,14 @@ | |
esutils "^2.0.2" | ||
js-tokens "^3.0.0" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.44.tgz#18c94ce543916a80553edcdcf681890b200747d5" | ||
dependencies: | ||
chalk "^2.0.0" | ||
esutils "^2.0.2" | ||
js-tokens "^3.0.0" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.42.tgz#7186d4e70d44cdec975049ba0a73bdaf5cdee052" | ||
|
@@ -55,6 +99,30 @@ | |
babylon "7.0.0-beta.42" | ||
lodash "^4.2.0" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f" | ||
dependencies: | ||
"@babel/code-frame" "7.0.0-beta.44" | ||
"@babel/types" "7.0.0-beta.44" | ||
babylon "7.0.0-beta.44" | ||
lodash "^4.2.0" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.44.tgz#a970a2c45477ad18017e2e465a0606feee0d2966" | ||
dependencies: | ||
"@babel/code-frame" "7.0.0-beta.44" | ||
"@babel/generator" "7.0.0-beta.44" | ||
"@babel/helper-function-name" "7.0.0-beta.44" | ||
"@babel/helper-split-export-declaration" "7.0.0-beta.44" | ||
"@babel/types" "7.0.0-beta.44" | ||
babylon "7.0.0-beta.44" | ||
debug "^3.1.0" | ||
globals "^11.1.0" | ||
invariant "^2.2.0" | ||
lodash "^4.2.0" | ||
|
||
"@babel/traverse@^7.0.0-beta.40": | ||
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.42.tgz#f4bf4d1e33d41baf45205e2d0463591d57326285" | ||
|
@@ -78,6 +146,14 @@ | |
lodash "^4.2.0" | ||
to-fast-properties "^2.0.0" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.44.tgz#6b1b164591f77dec0a0342aca995f2d046b3a757" | ||
dependencies: | ||
esutils "^2.0.2" | ||
lodash "^4.2.0" | ||
to-fast-properties "^2.0.0" | ||
|
||
"@ember-decorators/argument@^0.8.10": | ||
version "0.8.13" | ||
resolved "https://registry.yarnpkg.com/@ember-decorators/argument/-/argument-0.8.13.tgz#217804178c4278a8c264a2878b66c0cb55b77e3d" | ||
|
@@ -100,6 +176,15 @@ | |
ember-cli-babel "^6.6.0" | ||
ember-cli-version-checker "^2.1.0" | ||
|
||
"@ember-decorators/babel-transforms@^2.0.1": | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/@ember-decorators/babel-transforms/-/babel-transforms-2.0.1.tgz#75b668cfe996fa920c940ad723be015cddf904db" | ||
dependencies: | ||
babel-plugin-transform-class-properties "^6.24.1" | ||
babel-plugin-transform-decorators-legacy "^1.3.4" | ||
ember-cli-babel "^6.6.0" | ||
ember-cli-version-checker "^2.1.0" | ||
|
||
"@ember-decorators/utils@^0.2.0": | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/@ember-decorators/utils/-/utils-0.2.0.tgz#395362c75c4f85aa63aa7cbed77a6486fd6e5f22" | ||
|
@@ -637,6 +722,17 @@ babel-eslint@^8.0.3: | |
eslint-scope "~3.7.1" | ||
eslint-visitor-keys "^1.0.0" | ||
|
||
babel-eslint@^8.2.3: | ||
version "8.2.3" | ||
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.3.tgz#1a2e6681cc9bc4473c32899e59915e19cd6733cf" | ||
dependencies: | ||
"@babel/code-frame" "7.0.0-beta.44" | ||
"@babel/traverse" "7.0.0-beta.44" | ||
"@babel/types" "7.0.0-beta.44" | ||
babylon "7.0.0-beta.44" | ||
eslint-scope "~3.7.1" | ||
eslint-visitor-keys "^1.0.0" | ||
|
||
babel-generator@^6.26.0: | ||
version "6.26.1" | ||
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" | ||
|
@@ -1211,6 +1307,10 @@ [email protected], babylon@^7.0.0-beta.40: | |
version "7.0.0-beta.42" | ||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.42.tgz#67cfabcd4f3ec82999d29031ccdea89d0ba99657" | ||
|
||
[email protected]: | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.44.tgz#89159e15e6e30c5096e22d738d8c0af8a0e8ca1d" | ||
|
||
babylon@^5.8.38: | ||
version "5.8.38" | ||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-5.8.38.tgz#ec9b120b11bf6ccd4173a18bf217e60b79859ffd" | ||
|
@@ -3289,8 +3389,8 @@ ember-concurrency@^0.8.7: | |
ember-maybe-import-regenerator "^0.1.5" | ||
|
||
ember-data@^2.18.0: | ||
version "2.18.0" | ||
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-2.18.0.tgz#8e374e540ea7c3b101983eb51cd0beedaa4d230d" | ||
version "2.18.2" | ||
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-2.18.2.tgz#3c6e99c9aed77ef8945451c39f39865f370f3db4" | ||
dependencies: | ||
amd-name-resolver "0.0.7" | ||
babel-plugin-ember-modules-api-polyfill "^1.4.2" | ||
|
@@ -3322,7 +3422,7 @@ ember-data@^2.18.0: | |
semver "^5.1.0" | ||
silent-error "^1.0.0" | ||
|
||
ember-decorators@^1.3.2: | ||
ember-decorators@^1.3.2, ember-decorators@^1.3.4: | ||
version "1.3.4" | ||
resolved "https://registry.yarnpkg.com/ember-decorators/-/ember-decorators-1.3.4.tgz#801115ae1be9157bbb75280991ee3d07d12c6cce" | ||
dependencies: | ||
|
@@ -5468,8 +5568,8 @@ jju@^1.1.0: | |
resolved "https://registry.yarnpkg.com/jju/-/jju-1.3.0.tgz#dadd9ef01924bc728b03f2f7979bdbd62f7a2aaa" | ||
|
||
jquery@^3.2.1: | ||
version "3.2.1" | ||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787" | ||
version "3.3.1" | ||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca" | ||
|
||
js-base64@^2.1.8: | ||
version "2.4.3" | ||
|