Closed dvv closed 14 years ago
1) Do you have correctly created the schema, as described in http://github.com/akidee/schema.js/blob/master/README.markdown ?
You must not use new Schema(json) but Schema.create(json) for that all sub schemas will be instantiated as Schema instances! In this case, all schemas have fallbacks, that have the same names as the checkers, but prefixed with '__'.
2) Do you have run the tests test.js and plugins/default_test.js ? 3) If my advice does not help, please post a full example.
Thanks, Andi
Hmmm. I just copypasted the example from the github project page and it caused the errors. When I commented the erroneous code, there started throws at (!('minimum' in this.schema) and such.
Can you confirm the said example works ok for you?
TIA, --Vladimir
I have added the indroduction example: http://github.com/akidee/schema.js/blob/master/test.js#L14
In node v0.2.2, all tests work properly. Please check your node version.
Do you have fetched the latest http://github.com/akidee/extensions.js ?
node 0.2.0, your extensions of today, "Extended example: Google like search parameters" from readme. Failing... So does test.js -- same error. Seems something is broken at my side...
It should work in node v0.2.0 as well. To be sure, I have made a new commit. Fetch and check it out.
works ok now! Thanks. Seems the issue were in extensions.js, right?
I have fiddled around a lot with extensions in the past weeks and forgot to commit. Thank you for pointing me to the issue!
BTW, can you provide a separate "bundled" version of schema.js -- that is one file -- so we can reuse the code easily at client-side, in browsers. Would be very welcome, since then a client-side validation were made dirt-cheap plus it were 1-to-1 compatible with the server-side one.
It could be just a new file under schema.js hierarchy which would include schema.js per se plus extensions.js and would not use any require()
TIA, --Vladimir
Currently, this is not a solution I would recommend. Two causes:
1) Not all ECMA features, that schema needs, are supported by all browsers. I will use schema.js on the server-side only. This is a constraint, of course. I am already planning for the next version, and I am always trying to write my libraries as JavaScript implementation tolerant as possible. If possible, I will make the next v more compatible with the client-side. 2) Browsers should suport require(). In the world of RIA, that get more sophisticated, it is recommended to use a CommonJS implementation that works on the client-side. A promising project is http://requirejs.org/ Feel free to build a one file solution for yourself. Thanks.
I see. That coincides with my suspections :) Moreover, I'm inclined to consider client-side validation some kind of redundancy, since it's way easily bypassed.
Thanking for quick assistance and feedback, --Vladimir
Oh. Just another thing. Suppose I want to validate a partially defined instance. That is the case for bulk update, say, when I want to validate only properties that exist in the passed instance. How can I do so? In effect, silence errors due to a property being missing.
Hi!
http://github.com/akidee/schema.js/blob/master/index.js#L237 constantly throws since __type member is undefined. Typo?
--Vladimir