Skip to content

Relationship type expected ['string',null] actual 'object' #15

slaskis opened this Issue Nov 15, 2011 · 2 comments

2 participants

slaskis commented Nov 15, 2011

When defining a relationship like this:

this.Article = resourceful.define('article', function () {'name', String);

this.Category = resourceful.define('category', function () {'name', String);

it fails with a validation error when a Category is created alone a it has no linked Article (i.e. the article_id is null).

After some debugging i figured out that it was either of these problems:

  1. The relationships parent type is by default defined as: [String,null] where typeof null will be translated to 'object' which in turn makes it fail. Solution would be to change the type to ['string','null'] or [String,'null'].

  2. Revalidator (will post a issue/pull request there too) expects the types to be strings but does not enforce it so this section will always be ignored unless it's a string.

slaskis commented Nov 15, 2011

Personally I think prefer solution 2. that the validator should be fixed.

@indutny indutny added a commit that closed this issue Nov 15, 2011
@indutny indutny [resource] stringify types w/o constructors
* fix tests
* fixes #15
@indutny indutny closed this in e261eb4 Nov 15, 2011
indutny commented Nov 15, 2011

Thanks, fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.