Topic
3 replies Latest Post - ‏2013-10-18T15:16:25Z by MikeAA
magic798
magic798
34 Posts
ACCEPTED ANSWER

Pinned topic ValidationError when performing Search

‏2013-10-17T15:39:12Z |

Hi,

 

we're developing a requestfilter plugin on "/cm/search" that checks for example if certain fields contain a certain value. If they are not filled in properly then an error is returned and ICN should render a validation error, similar to what happens when we save a document and validation fails.

The JSON containing the error that we're returning is:

 

{"fieldErrors":[{"symbolicName":"KlantID_TR5_15","errorMessage":"Klant should contain value A, B or C!"}]} 

However this has no effect. It simply shows 0 search results and no error is displayed.

My question is: what exactly should the response from the requestfilter be such that the search is aborted and the field mentioned shows a validation error?

 

Kind regards,

 

magic798

  • BJOwings
    BJOwings
    185 Posts
    ACCEPTED ANSWER

    Re: ValidationError when performing Search

    ‏2013-10-17T18:12:21Z  in response to magic798

    The fieldErrors is not looked for on a response from the search.  (This is used for field validation by EDS which is not supported on search.)  So, displaying an error on a particular field will not work.  Instead, you can display an error dialog using a normal error response:

    
    {"errors":[{"text": "Invalid value", "explanation":"Klant should contain value A, B, or C!
    ","number":"10001","userResponse":"Enter a valid value for Klant"}]}
    

    The choice of error number is yours, but you should choose one out of the range of ICN's errors.