Fields¶
Fields are the validation/cleaning mechanic of tinyobj. Each is responsible for receiving a value (from the database, for example), cleaning it, and returning the cleaned value. A reference to the original value is not kept at this time, so reserializing the data for your specific use case is left as an exercise to the reader.
The base object is Field, of which TinyObj will detect subclasses to use as fields:
Subclasses¶
tinyobj implements a number of fields to do validation, etc.
- class tinyobj.fields.NumberField(t=<type 'float'>, allow_negative=True, allow_positive=True)[source]¶
accept and validate numbers
takes a type to convert values to, can be (EG) float, int, long, or complex.
- class tinyobj.fields.BoolField(default=False)[source]¶
accept and validate boolean values
note that this field will just call bool on values, this may not be your desired behavior so you might want to implement a subclass that parses truthy/falsey values in a way specific to your application