Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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