Skip to content

Commit 3aa4923

Browse files
committed
* [x] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
* [x] Have you added an explanation of what problem you are trying to solve with this PR? It is needed for returning attributes like ```` <saml:Attribute Name="dateOfBirth"> <saml:AttributeValue xsi:type="xs:date">2015-12-06</saml:AttributeValue> </saml:Attribute> ```` Otherwise I get an ValueError Exception like ```` Type and value do not match: date:<class 'str'>:2015-12-06 ```` because `type(value) is not valid_type == True` I didn't write any unit test, just tested in my context. Two important things: 1. This PR is on top of #597 but it doesn't have any dependencies on it. The only file I changed is saml.py, let me know if this PR will be merged in next releases and if you need separate branch for every features. In the future I will this way. 2. I think that the following code https://github.com/IdentityPython/pysaml2/pull/602/files#diff-6c156669cad61eda35e679329251dce9R197 could be also improved according to #518
1 parent 79b9f30 commit 3aa4923

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/saml2/saml.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Generated Mon May 2 14:23:33 2011 by parse_xsd.py version 0.4.
55
#
66
import base64
7+
import datetime
78

89
from saml2.validate import valid_ipv4, MustValueError
910
from saml2.validate import valid_ipv6
@@ -191,6 +192,11 @@ def _wrong_type_value(xsd, value):
191192
'to_type': _str,
192193
'to_text': _str,
193194
},
195+
'date': {
196+
'type': datetime.date,
197+
'to_type': lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(),
198+
'to_text': _str,
199+
},
194200
'integer': {
195201
'type': int,
196202
'to_type': int,

0 commit comments

Comments
 (0)