Domain Object Validation in play - scala

I am trying to implement some domain object validation in Play 2 with scala in my REST based project. For the same project which was a in java earlier we use oval for that purpose. Any one can help me out by any such kind of validation tool to work with case class or at the JSON conversion. Any thing do we have in play framework to do this kind of domain object validation.
Any help will be highly appreciated...

Check out play json framework:
https://www.playframework.com/documentation/2.6.x/ScalaJson
It is a very powerful framework for validating JSON objects

Related

JAX-RS Struts2 REST API

Why would one like to integrate JAX-RS(Jersey) using Rest API to Struts2? Struts2 is itself a mvc framework, so why would anyone want to integrate these both? If combined, how will the resulting framework be(I wanted to know if REST API just control the controller part of MVC).
There is a RESTful plugin called struts2-rest-plugin that has been included with the framework since version 2.1.1. A fair amount of information on the plugin can be found here.
Essentially, the plugin uses a custom action mapper that examines the request and based upon the HTTP Method used in conjunction with the URI, it dispatches the request to one of several different method names (e.g. GET /movies dispatched to index() method of action).
Just because Struts2 is an action-based framework does not mean a RESTful solution cannot be included as an alternative for developers. Spring MVC offers similar solutions themselves and it is also an action-based framework.
If you consider your JSON response as your view, you'll see that the fact that Struts2 is based on MVC design makes logical sense. Your model is simply the data structure you are returning to the client and your controller is the action.
Consider reading the link above on the plugin and you'll get a better picture of how the two can be integrated. If you want to return JSON but don't necessarily want to offer RESTful URLs in your Struts2 application, you can also consider the JSON plugin, found here.
I am not sure about Struts2, but in the past Struts1 did not have a "Rest" adapter built in. Jersey provides the cool #annotations that will easily serialize your datamodel and will push you in a "Restful" direction. Jersey does not provide an MVC framework as much as it provides convenience methods to work in a Restful/resource based way.

ReactiveMongo & JSON4S

I'm using JSON4S to parse some JSON strings I'm getting from external APIs.
Is there anyway to get JSON entities like there is with the play reactivemongo JSONCollection or the spray-json to reactive mongo converter in sprest?
Its easy to use JSON4S with the standard Mongo Casbah lib e.g. builder.insert(JObjectParser.parse(obj))
But I really want to be able to do this with reactivemongo.
You can start by taking a look at how it's implemented in play-reactivemongo plugin (conversion between play's js reads/writes and reactivemongo's types) here.
I know this is an old question, but this is always the first thing that pops up when I google it.
I've begun working on a project that does this based on the Play Framework's plugin.
Check the issue tracker, because there are currently some problems that may make using it not an option.
https://github.com/Jacoby6000/Json4s-reactivemongo-compatibility

disable gwt obfuscation for certain model classes

Is it possible in GWT 2.4+ to disable obfuscation for certain java model classes?
The reason I am asking this question is we use GWT RPC to talk to the server and need to store these objects returned etc in local storage using the Indexed DB API, we are currently using websql api. If GWT obfuscates/renames your properties etc then this renders using the Indexed DB API useless in your code.
Maybe there is a way to ask GWT to replace a property string with the obfuscated version in your Indexed DB api queries?
I could create a whole new java model that uses javascript overlays so these are preserved when GWT compiled and replace GWT RPC with JSON RPC but this would be a lot of work.
Any other ideas would be appreciated!
I also looked at the AutoBean framework which produces nice JSON output of your model interfaces but I don't think has a nice simple javascript representation under the hood.
You can set GWT Compile style attribute to PRETTY or DETAILED. so that GWT will not replace the class, method or variable names. For more information refer this link.

how to use DataAnnotations in desktop application

When we are using EF (f.e.) via MVC, we can use ModelState.IsValid to detect a model can pass DataAnnotations metadata or not. But how can I use DataAnnotations metadata in a desktop (win-forms / wpf) application?
More:
In fact, I want to create an object same as ModelState (a dictionary that can save properties and messages associated with each). Then, wrap the DAL by a validation-layer, in VL use metadata to validate models, that the VL can be used in any project. I know I should use reflector, but I haven't any experience. Thanks to any help and suggestion.
If you are using EF 4.1/4.1 dbcontext, it has a built in validation API that can check Data Annotation rules as well as IValidatableObject.Validate. I'm not quite sure that I understand your goal, but if it is to have the validation in the data layer then you can just use what's built in. (Here's an overview http://msdn.microsoft.com/en-us/data/gg193959).
If you want your own validator that is separate from the data layer, then look at the System.ComponentModel.DataAnnotations namespace for methods and other logic you can leverage to do your own validation.

Using the Validation Block of Enterprise Library with Entity Framework

We've used the Validation Block of MS Enterprise Library for some time with great success in conjunction with custom DALs but we've recently started using the Entity Framework and can't get the Validation Block to work with it. The objects are dynamically created in EF and putting attributes on top of them will simply get wiped out when the models are re-genned.
Can these two co-exist? If not, does anyone have any recommendations for what validation library/simple rules engine would be a good candidate to use along with EF?
Thank you.
You need a validator which supports a "buddy class" (like this example for Dynamic Data). This seems to be a work in progress for VAB. I can't find an example of anyone actually using it yet, but it might work.
Validation Application Block supports the concept of configuration based validation. This way you can separate your generated domain entities from validation. You can use the Enterprise Library configuration tool for this. Simply right-click on your configuration file and start adding validation configuration.
I advise you to read the VAB Hands on Lab document (ValidationHOL.pdf) which is included in the Hands On Lab download. After reading that document, read this article. It explains how to integrate VAB with Entity Framework.
Good luck.