aboutsummaryrefslogtreecommitdiff
path: root/lesana/collection.py
diff options
context:
space:
mode:
Diffstat (limited to 'lesana/collection.py')
-rw-r--r--lesana/collection.py16
1 files changed, 16 insertions, 0 deletions
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='.'):