Skip to content

+ [feature] supports the enum/in can use object to transform value#67

Open
snowyu wants to merge 2 commits intosailshq:masterfrom
snowyu:feature/enum-object
Open

+ [feature] supports the enum/in can use object to transform value#67
snowyu wants to merge 2 commits intosailshq:masterfrom
snowyu:feature/enum-object

Conversation

@snowyu
Copy link

@snowyu snowyu commented Dec 12, 2014

see https://github.com/balderdashy/waterline/issues/52

attributes: {
  state: {
    type: 'int',
    enum: {'pending':2, 'approved':3, 'denied':4]
  }
}

@snowyu
Copy link
Author

snowyu commented Dec 12, 2014

this PR needed too: validatorjs/validator.js#336

@particlebanana
Copy link
Contributor

Looks like he merged the PR on validator so can you can update this and remove the override? Also in the test/util/testType.js can't the isRule part be removed and just test the enum?

@snowyu
Copy link
Author

snowyu commented Dec 12, 2014

the Author merged the PR partly: test the key whether in an object only, instead of the key and value testing.

But the Anchor.match.type() passes the value and type arguments only, no additional rule information passed. So once the 'this.data' is replaced to the value, the 'in' rule will raise error if no value testing.

Maybe you have a good idea for this.

I think may be some other types(required the whole rule infomation) need this testType helper function too. To keep compatibility I have to add the isRule argument. To get rid of isRule argument, maybe should I test the type whether is object and the object hasOwnProperty 'type'? but it would not work if type object can have the "type" property too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants