@@ 208-223 (lines=16) @@ | ||
205 | return super().to_ogm(val) |
|
206 | ||
207 | ||
208 | class Boolean(abc.DataType): |
|
209 | """Simple boolean datatype""" |
|
210 | ||
211 | def validate(self, val: Any): |
|
212 | try: |
|
213 | val = bool(val) |
|
214 | except ValueError: |
|
215 | raise exception.ValidationError( |
|
216 | "Not a valid boolean: {val}".format(val)) from e # type: ignore |
|
217 | return val |
|
218 | ||
219 | def to_db(self, val=None): |
|
220 | return super().to_db(val=val) |
|
221 | ||
222 | def to_ogm(self, val): |
|
223 | return super().to_ogm(val) |
|
224 | ||
@@ 152-167 (lines=16) @@ | ||
149 | return super().to_ogm(val) |
|
150 | ||
151 | ||
152 | class String(abc.DataType): |
|
153 | """Simple string datatype""" |
|
154 | ||
155 | def validate(self, val): |
|
156 | if val is not None: |
|
157 | try: |
|
158 | return str(val) |
|
159 | except ValueError as e: |
|
160 | raise exception.ValidationError( |
|
161 | 'Not a valid string: {}'.format(val)) from e |
|
162 | ||
163 | def to_db(self, val=None): |
|
164 | return super().to_db(val=val) |
|
165 | ||
166 | def to_ogm(self, val): |
|
167 | return super().to_ogm(val) |
|
168 | ||
169 | ||
170 | class Integer(abc.DataType): |