diff options
-rw-r--r-- | docs/field_types.rst | 2 | ||||
-rw-r--r-- | lesana/collection.py | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/docs/field_types.rst b/docs/field_types.rst index 89065aa..baf2c5e 100644 --- a/docs/field_types.rst +++ b/docs/field_types.rst @@ -10,6 +10,8 @@ integer: . float: . +decimal: + . timestamp: . boolean: diff --git a/lesana/collection.py b/lesana/collection.py index 464dbde..a8980eb 100644 --- a/lesana/collection.py +++ b/lesana/collection.py @@ -1,3 +1,4 @@ +import decimal import logging import os import uuid @@ -56,6 +57,10 @@ class Entry(object): data += ("{name}: |\n .\n".format(**field)) elif t == 'integer': data += ("{name}: 0\n".format(**field)) + elif t == 'float': + data += ("{name}: 0.0\n".format(**field)) + elif t == 'decimal': + data += ("{name}: 0.00\n".format(**field)) elif t == 'list': data += ("{name}: []\n".format(**field)) else: @@ -105,6 +110,17 @@ class Entry(object): value ), }) + elif t == 'decimal': + try: + decimal.Decimal(value) + except ValueError: + valid = False + errors.append({ + 'field': field['name'], + 'error': 'Invalid value for decimal field: {}'.format( + value + ), + }) return valid, errors def render(self, template, searchpath='.'): |