tilemill-project / tilemill

TileMill is a modern map design studio
https://tilemill-project.github.io/tilemill/
BSD 3-Clause "New" or "Revised" License
3.12k stars 528 forks source link

Replace JSV parser #930

Closed willwhite closed 8 years ago

willwhite commented 13 years ago

We need a lightweight JSON schema parser that can run in the browser and allow us to provide custom error messages.

miccolis commented 13 years ago

@willwhite it looks like @Vertice may have tracked down a "better JSV" - https://github.com/Baggz/Amanda

He's going to be evaluating it the next day or so, but it looks promising.

AdrianRossouw commented 13 years ago

I wrote some tests in mocha to evaluate it, but I had to solve some pretty minor issues in amanda itself to get it to work.

I used the project schema and fixtures from tilemill to do the tests against, but I am not sure of it's completeness. The is no guarantee that when we write a constraint in our schemas they actually end up performing any or even the correct validation.

It's browser support also doesnt seem complete.

AdrianRossouw commented 13 years ago

One important wrinkle in the JSV implementation found in tilemill and other bones sites, is that unless you set an id on the model.schema, you will be unable to re-use a previously instantiated validation object and it will re-run the createSchema every time the validate function is called, which is could also be every time .set() is called.

Adding the 'id: "project"' line to the project schema should cause significant speed increases.

AdrianRossouw commented 13 years ago

While i am going through bones to find a general issue to the above problem, i looked into trimming down JSV a bit. You do not need the other environments to be sent to the client if you aren't validating against them, and the file sizes were as follows:

  1. concat all requirements into one file - 115k
  2. uglify.js - 44k
  3. uglify + gzip - 11k
yhahn commented 12 years ago

Closing.

springmeyer commented 11 years ago

@yhahn's commit above (adding ID's to each schema) seems unrelated to this issue, and we are still using JSV, so re-opening.