TypeError when defining a pattern for string in Resourceful

29 views
Skip to first unread message

Eric Chaves

unread,
Apr 29, 2012, 1:33:55 AM4/29/12
to flati...@googlegroups.com
Hi Guys,

I'm not sure if this is the right place to post questions related to Resourceful, but I'm assuming it is since it is part of Flatiron project. If I"m mistaken, please excuse me.
I'm trying to get a good understand about Resourceful features and this has being a challenge since Flatiron (and it's components) seems to lack a lot when comes to documentation. This lead me to read a lot of code and since I'm far from being a javascript ninja, there is a good chance that I'm missing something here.

I'm trying to define a regexp pattern for a property string like this:

User.string('username').pattern(/^[a-zA-Z0-9]{3,15}$/).required(true).unique(true);

However I'm getting a TypeError. Digging into the code this is raised by common.typeOf function when it evaluate this type. This function check the typeof of the value to decide and for the regexp it expects that typeof(/regexp/) to be "function" but I'm getting "object" which makes the validation fails and the function to assume that the value informed is not a regexp.

Am I informing the pattern in the right way? If so, is this behavior a bug in Resourceful or is it in V8 implementation of typeof(/regexp/)?

Thanks in advance,

Eric

Richard Marr

unread,
Apr 30, 2012, 4:58:16 AM4/30/12
to flati...@googlegroups.com
*Tumbleweed*

Hi Eric, 

I'd suggest adding this as an issue on the Resourceful project's Github page:

In the meantime you could work around the problem by passing in a function rather than a RegExp  (as you probably already know). 

It might take a little while to be addressed though. I'm actually considering packaging my own fork of the project in npm, and delays on comments/fixes/pull-requests are part of the rationale.

Rich
--
Richard Marr

Charlie Robbins

unread,
Apr 30, 2012, 10:29:51 PM4/30/12
to flati...@googlegroups.com
Eric,

This sounds like a bug, but it also could be a bug in revalidator (the JSON schema validation library used by resourceful), not resourceful itself.

Could you see if a plain revalidator example fixes the issue so we can narrow down the scope of the bug? http://github.com/flatiron/revalidator

Thanks,
Charlie

Joshua Holbrook

unread,
Apr 30, 2012, 10:51:14 PM4/30/12
to flati...@googlegroups.com
> *Tumbleweed*

I try to pay attention to this mailing list as best I can, but
sometimes I miss a post or two. This is still a fairly quiet mailing
list, so threads don't tend to get bumped in gmail. :(

@Eric: Filing issues on the projects is a good idea. We're quite good
at keeping an eye on the comments in our github issues.

> Flatiron (and it's components) seems to lack a lot when comes to documentation.

I know some of the projects are less well-documented than others. I've
written a large chunk of the flatiron/flatiron readme, myself.

Two things: One, if you find something confusing, let us know! Like I
said, I try to pay attention to this mailing list, and other good
places to look for help include #nodejitsu on irc.freenode.net .
Second, if you find something confusing and then figure out the answer
and don't mind helping out, I would *love* some help. XD

> I'm actually considering packaging my own fork of the project in npm, and delays on comments/fixes/pull-requests are part of the rationale.

@Rich it would be great to have more developers involved with the
resourceful project. Right now the pool of contributors is relatively
small, and I would hate to see you make your own fork due to a
breakdown in communication.

--Josh
--
Joshua Holbrook
Engineer
Nodejitsu Inc.
jo...@nodejitsu.com

Eric Chaves

unread,
May 1, 2012, 1:19:19 AM5/1/12
to flati...@googlegroups.com
Hi Guys,

Thanks all for the help. Just to summarize and keep thinks updated, I already opened an issue in github and the issue was addressed with a very productive discussion (at least for me who still learning the ins & outs of nodejs).

Just wish to say that I really liked the work done by you guys with the entire Flatiron project and it's components. I really like the approach of having small, light-weight components orchestrating together. I was a little frustrated by the fact that it does not have an engine for mongo-db. Also the documentation still require some polishing.

But anyway congratulations for the great work!

Cheers,

Roly Fentanes

unread,
May 1, 2012, 1:24:10 AM5/1/12
to flati...@googlegroups.com

Richard Marr

unread,
May 1, 2012, 5:54:58 AM5/1/12
to flati...@googlegroups.com
> @Rich it would be great to have more developers involved with the
> resourceful project. Right now the pool of contributors is relatively
> small, and I would hate to see you make your own fork due to a
> breakdown in communication.

I think I've sent the most pull requests so far, but the effort/reward ratio is getting steeper for me. The response rate for comments, bugs and pull requests is pretty slow, and my stack is on Node 0.4.7, which had support dropped recently.

I know everyone's busy on other stuff, and that keeping effort in one place makes the project stronger... it's just a bit of a drag on getting stuff done.

Is there a Node version people are using in the 0.6.x range that's got decent dependency support? Last time I tried to upgrade my stack was 0.4.10 and it got ugly.




--
Richard Marr

Eric Chaves

unread,
May 1, 2012, 10:20:53 AM5/1/12
to flati...@googlegroups.com
I did tried that but it was in very early stage and the lead developer said he has no intentions of keeping it up. The reason claimed is that the design of resourceful engine is very driven towards couchdb and other HTTP based databases, which makes certain operations very hard to be implemented. He is now maintaining mongo-col (https://github.com/Raynos/mongo-col) which is a wrapper around mongodb native driver.
 
This is not the first time I hear such opinion about resourceful engine. In fact almost all developers that I could get in touch and that has done something using resourceful and mongodb told me the same thing. They all gave-up on writing a mongodb engine.

If I may give my honest opinion, I don't see this as flaw in resourceful design actually. On the contrary, I really like the idea of a schema component that is independent of any database/store. But this certainly indicates that the engine should be reviewed somehow. I can't comment on the engine design however since I haven't studied it yet.

As for the moment I'm following this path: I'm writing a standalone database layer based on the mongo-db native driver so I can learn a bit more of the native driver. Than I'll figure what to do. ;)

Cheers,

Eric
Reply all
Reply to author
Forward
0 new messages