Hi,

The validation function returns {error, [ErrorMessages]}

What I do is that I receive it in {error,ErrorList}
I think this is what makes ErrorList a list.

I think what you are doing is that you are receiving it as 
{error,[ErrorList]}
and then doing a {json,[{error,ErrorList}]}
This would work fine if you knew for sure there was only one validation 
error. But when you have more than one validation errors then I think this 
code will break.

In my case, I can get more than one validation errors.
Hence, I have to receive it as a list - {error,ErrorList}
But if I directly json it, I get an array of numbers in output.
So, I instead do {json, [{error,list_to_binary(ErrorList)}]}

This works in my case, giving a string json output.
What also works is this: {json, [{error,io_lib:write_string(ErrorList)}]}

In the previous mail I had also mentioned unicode:character_to_binary. That 
however does not seem to work in case of a list of more than one error 
strings so that was incorrect.

Please forgive me if I misunderstood you - I am new to Chicago Boss (and 
Erlang) :)

Thanks
Jitin




On Tuesday, 28 October 2014 20:33:52 UTC+5:30, can2nac wrote:
>
> i use it in the same instance and validation function returns binary 
> string, not the list, for example <<"name">>
>
> On Tuesday, October 28, 2014 1:20:43 PM UTC+3, Jitin Luthra wrote:
>>
>> Hi,
>> Thanks for the correction. I use these for the model validation function 
>>  which returns a list of strings called ErrorMessages if validation fails:
>> {error, [ErrorMessages]}
>> It works in this case.
>>
>> Thanks
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/7dfb3da1-b6fc-4093-a896-0b4caa9a8d44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to