You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Todd O'Bryan <to...@gmail.com> on 2015/11/14 00:37:22 UTC

More granular specification of data?

Hey all,

Thrift looks really cool, but I'm wondering if it can handle a use case.

Is there any way to specify more specific constraints on data? For example,
say you knew that userId was a string between 8 and 24 characters. Is there
any way to specify that in the data representation? Other examples would be
regexes for strings, or ranges for integers, etc.

I'm guessing this would be really hard to do cross-linguistically, but it
would be really nice to be able to provide clients with code that would
validate their messages before they send them.

Looking around, all I've seen that does this kind of thing are XML Schema
and JSON Schema, and, of course, nobody wants to deal with XML and JSON if
they can avoid it. :-)

Thanks,
Todd

Re: More granular specification of data?

Posted by Randy Abernethy <ra...@gmail.com>.
Hey Todd,

Design by contract! Would be a nice thing but no such beast in the thrift
abstraction (though someone or some language may have some bits, never seen
Thrift for Eiffel ...).

Best,
Randy

On Fri, Nov 13, 2015 at 3:37 PM, Todd O'Bryan <to...@gmail.com> wrote:

> Hey all,
>
> Thrift looks really cool, but I'm wondering if it can handle a use case.
>
> Is there any way to specify more specific constraints on data? For example,
> say you knew that userId was a string between 8 and 24 characters. Is there
> any way to specify that in the data representation? Other examples would be
> regexes for strings, or ranges for integers, etc.
>
> I'm guessing this would be really hard to do cross-linguistically, but it
> would be really nice to be able to provide clients with code that would
> validate their messages before they send them.
>
> Looking around, all I've seen that does this kind of thing are XML Schema
> and JSON Schema, and, of course, nobody wants to deal with XML and JSON if
> they can avoid it. :-)
>
> Thanks,
> Todd
>