-
Notifications
You must be signed in to change notification settings - Fork 419
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
Schemas validation #31
Comments
For example, generate Angular forms from JSON schema http://schemaform.io/ |
I don't quite get this. How is that different from daybed? I would propose anyone who can create a collection can also create a schema. |
I think this is handled by the "bucket" concept.
That's a good question. I believe in this case it should be possible to iterate on all the records and apply a function to them, maybe?
In case we download data from somewhere, we assume it's already validated by the server, so I don't get where the problem lies here?
I think we should do that but would need to explore the json schema spec further to understand better how to do that. Also, I think json schema has one big problem: its complexity. It doesn't seem to be simple to use it. As such, we could probably provide a way to create schema in an easy way, which would then map to the standard? |
Unlike Daybed, the collections are not global. It means that as a user, I can associate a schema to my
Nope, what I meant with this was mozilla-services/cliquet#243.
I was wondering what happens if two users have a different schema for the same collection name.
I wouldn't go that way. Maybe if it's too complex, then we can imagine a WYSIWYG JSON schema builder ? |
Then we agree :-) However, the notion of "own" differs a little: with buckets, a resource can have multiple owners. Gotcha about how we should store the schemas. This should be handled by mozilla-services/cliquet#243 then.
We need some kind of namespacing here (and I believe this is achieved through buckets). Like on github: leplatrem/cliquet differs from ametaireau/cliquet.
I don't know the json schema spec well enough to make a call, but it seems that it would be harder to do it that way than allowing a simpler format. |
Validate JSONSchema for collections (ref #31)
Let's start a discussion about schema validation !
I believe we want something similar to Daybed. Except that we won't
reinvent the wheel with custom schema formalism.
It looks like there is no way around JSON schema. We won't rewrite thousands
of lines of code using Colander (see https://github.com/Julian/jsonschema).
We will use existing validators, and frontends will build forms from schemas.
By default, collections could be schemaless.
It is acceptable if the validation of the definition is done using Cornice/Colander.
Even though there are meta-schemas :)
If a schema exists for a collection, records that don't match the schema are
refused with
400 Bad Request
(on PUT and after merge of PATCH).Unlike Daybed, I propose that each user owns the schema of the collection.
Especially because the schema endpoint will probably be a resource :)
Schemas could be cached to avoid overhead of reading it from storage at each incoming record.
This implies that users can store heterogeneous data with the same collection name.
Hence, on first start, the JS application will have to check that the user did
not set any schema (e.g. at
/collections/moz:readinglist:articles/schema
).If she did, then confirm to replace it. If she hacks it afterwards and stores
invalid records, the JS application may crash, but that's okay.
Open questions
PUT or PATCH ?
records crash our application when fetching shared records ? We could probably
run client-side validation using JSON schema on shared records.
I'm thinking of recurrent needs for uuid4, geohash, GeoJSON objects, phone, postal codes...
The text was updated successfully, but these errors were encountered: