[protobuf] Re: Numeric range not supported?

2013-10-22 Thread amalhotra15 . 9
Ben - Could you show some examples on using FieldOptions for this kind of 
validation? How would you map the actual field name to its validation rules?


On Thursday, June 2, 2011 10:31:34 PM UTC-4, Ben Wright wrote:

 You can use custom field options to support validation of this type. 

 Take a look at extending com.google.FieldOptions 

 You can create an option field like max_inclusive and then access it 
 at run-time from the FieldDescriptor and use the information for 
 validation. 

 Unfortunately this is still just a suggestion - you will still have 
 to validate with custom-written code. 

 PS:  I have done this before and it worked out pretty well because the 
 validation code did not have to have special information about the 
 data structure, just access to the FieldDescriptor at run time. 

 On May 30, 6:54 am, Marco Tedone marco.ted...@gmail.com wrote: 
  Hi all, 
  
  I'm checking the protobuf language definition and I couldn't find 
  anywhere support for numeric range. In XSD, for instance, one could 
  have: 
  
  simpleType name=ZeroToTen 
  restriction base=int 
minInclusive value=0 / 
maxInclusive value=10 / 
  /restriction 
   /simpleType 
  
  However I couldn't find equivalent translation in the proto language 
  definition. I could find defaults and enums, but not number ranges. 
  
  Regards, 
  
  Marco

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


[protobuf] Re: Numeric range not supported?

2011-06-02 Thread Ben Wright
You can use custom field options to support validation of this type.

Take a look at extending com.google.FieldOptions

You can create an option field like max_inclusive and then access it
at run-time from the FieldDescriptor and use the information for
validation.

Unfortunately this is still just a suggestion - you will still have
to validate with custom-written code.

PS:  I have done this before and it worked out pretty well because the
validation code did not have to have special information about the
data structure, just access to the FieldDescriptor at run time.

On May 30, 6:54 am, Marco Tedone marco.ted...@gmail.com wrote:
 Hi all,

 I'm checking the protobuf language definition and I couldn't find
 anywhere support for numeric range. In XSD, for instance, one could
 have:

 simpleType name=ZeroToTen
         restriction base=int
           minInclusive value=0 /
           maxInclusive value=10 /
         /restriction
  /simpleType

 However I couldn't find equivalent translation in the proto language
 definition. I could find defaults and enums, but not number ranges.

 Regards,

 Marco

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.