You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've used this library in a small project and it server really well for my purposes. I'm now considering its use in larger projects, but the idea of having two sets of rules (front-end and back-end) in order to validate the same model seems to violate the DRY principle.
json-schema are useful because they provide a formal description of the data a given service is supposed to produce and/our consume. Depending on your development methodology, you can use it to automatically generate Java (or other language of choice) objects that can be de/serialized to the a compliant JSON representation. You also have the option to generate the schema from existing classes, though this path has some limitations.
Given this scenario, I was wondering that it would be very nice if I could derive validation rules straight from a json schema.
where 'someJsonSchema' is a json-schema object retrieved somehow.
There are a number of json-schema javssscript implementations, but none of them (as far as I know) can deal with observables(). One way would be to simply unwrap the structure and use the existing libraries, but this seems inefficient, specially for complex data structures.
WDYT ?
The text was updated successfully, but these errors were encountered:
I'd not seen json-schema before and it looks like it would be a good format, but I suspect we would need a way to convert json-schema to rule definitions. Once we can do that they we could use the feature above to achieve this.
If you are familiar with this then feel free to submit a conversion and we'll see what we can do.
Hi,
I've used this library in a small project and it server really well for my purposes. I'm now considering its use in larger projects, but the idea of having two sets of rules (front-end and back-end) in order to validate the same model seems to violate the DRY principle.
json-schema are useful because they provide a formal description of the data a given service is supposed to produce and/our consume. Depending on your development methodology, you can use it to automatically generate Java (or other language of choice) objects that can be de/serialized to the a compliant JSON representation. You also have the option to generate the schema from existing classes, though this path has some limitations.
Given this scenario, I was wondering that it would be very nice if I could derive validation rules straight from a json schema.
So, instead of this:
mymodel.observable1.extend( rule );
mymodel.observable2.extend( rule );
...
mymodel.a.nested.observable2.extend( rule );
mymodel.a.very.very.very.very.deepply.nested.observable2.extend( rule );
...
One could just do like that:
mymodel.extend(schema:someJsonSchema)
where 'someJsonSchema' is a json-schema object retrieved somehow.
There are a number of json-schema javssscript implementations, but none of them (as far as I know) can deal with observables(). One way would be to simply unwrap the structure and use the existing libraries, but this seems inefficient, specially for complex data structures.
WDYT ?
The text was updated successfully, but these errors were encountered: