Search code examples
node.jsmongodbbreeze

Are client and server side validations supported in breeze when using the MEAN stack?


I went through the Zza sample where BreezeJS is used in combination with an NodeJS (+ MongoDb) backend.

http://www.breezejs.com/samples/zza

In the sample there is no client nor server side validation implemented as we can do with a .Net backend. Is this simply not possible when using breeze + MongoDb or is it just not present in the sample? The big difference with the .Net backend is that the meta data are stored client side and not autogenerated from the server. Can we assume that something similar will be possible one day with MongoDb ? Is Breeze + MEAN production ready or is it still beta material?


Solution

  • Client side validation in Breeze is not dependent on the server. You can define validations directly on the client. There are plenty of examples of this in the documentation for the other non Mongo providers, but the code is the same. In terms of metadata coming from the server, since MongoDB has no schema there is no way to return what would be nonexistent metadata to the client. The only way to do this would be if you were to also use something on the server that more strongly typed the Mongo data ( i.e. something like Mongoose). This has been a request on the Breeze User Voice.

    We have not yet created a Mongo example where we automatically validate the data on the server before saving, but this shouldn't be that much of a stretch, but it will be "custom" code.

    In terms of being production ready, we are still adding features to the breeze ecosystem, both on the client and the server. However, we do try to limit the number of breaking changes.