Devanshu,

You can simply try to use override to override the default behavior of
auto-attribute. For example; if you are working on PartyContanctMech and
you want partyId and contactMechId should return custom error message if
empty. Then use the following practice to do that;

<auto-attributes include="pk" mode="IN" optional="false"/>
<override name="partyId" optional="false">
    <type-validate>
         <fail-message message="party id is required field." />
    </type-validate>
</override>


Override tag intended to override the default behavior set in the
auto-attributes. Simply using it suggested and implemented at service
defintion level.


HTH!



Rishi Solanki
Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com

On Thu, Oct 13, 2016 at 11:14 AM, Devanshu Vyas <vyas.devansh...@gmail.com>
wrote:

> Hello Guys,
>
> I came across a situation where I tried to throw a custom
> (more user-friendly) validation message when a required field in a service
> is missing. And the service definition was written with auto-attributes,
> something like this:
>
> <auto-attributes include="pk" mode="IN" optional="false"/>
>
> And I found myself stuck as I wanted to throw a custom message on a
> specific field among the PKs of the entity.
>
> I want you to suggest me a way to set validate message in such situation
> like we set on a single attribute like:
>
> <attribute name="shippingContactMechId" type="String" mode="IN"
> optional="false">
>     <type-validate>
>         <fail-property resource="OrderUiLabels"
> property="checkhelper.select_shipping_destination"/>
>     </type-validate>
> </attribute>
>
> IMO, we can think of doing something like the exclude field inside the
> auto-attributes to define the validate messages on the fields.
>
> <auto-attributes include="pk" mode="IN" optional="true">
>     <exclude field-name=""/>
> </auto-attributes>
>
> Something like this:
>
> <auto-attributes include="pk" mode="IN" optional="true">
>     <validation-message field-name="shippingContactMechId"
> resource="OrderUiLabels"
> property="checkhelper.select_shipping_destination"/>
> </auto-attributes>
>
> Please share your thoughts. :)
>
> --
> Thanks and Regards,
> Devanshu Vyas
>

Reply via email to