| |
@@ -470,6 +470,43 @@
|
| |
viewonly=True,
|
| |
)
|
| |
|
| |
+ @validates('name')
|
| |
+ def validate_name(self, key, name):
|
| |
+ if not name:
|
| |
+ raise AssertionError('No username provided')
|
| |
+ if type(name) != six.text_type:
|
| |
+ raise AssertionError('Name must be a string')
|
| |
+ return name
|
| |
+
|
| |
+ @validates('description')
|
| |
+ def validate_description(self, key, description):
|
| |
+ if not description:
|
| |
+ raise AssertionError('No description provided')
|
| |
+ if type(description) != six.text_type:
|
| |
+ raise AssertionError('Description must be a string {0}'.format(type(description)))
|
| |
+ return description
|
| |
+
|
| |
+ @validates('namespace')
|
| |
+ def validate_namespace(self, key, namespace):
|
| |
+ if namespace:
|
| |
+ if type(namespace) != six.text_type:
|
| |
+ raise AssertionError('If you type namespace, please make it a string')
|
| |
+ return namespace
|
| |
+
|
| |
+ @validates('url')
|
| |
+ def validate_url(self, key, url):
|
| |
+ if url:
|
| |
+ if type(url) != six.text_type:
|
| |
+ raise AssertionError('If you type url, please make it a string')
|
| |
+ return url
|
| |
+
|
| |
+ @validates('avatar_email')
|
| |
+ def validates_avatar_email(self, key, avatar_email):
|
| |
+ if avatar_email:
|
| |
+ if not re.match("[^@]+@[^@]+\.[^@]+", avatar_email):
|
| |
+ raise AssertionError('If you type avatar_email, please make it a real email')
|
| |
+ return avatar_email
|
| |
+
|
| |
@property
|
| |
def isa(self):
|
| |
""" A string to allow finding out that this is a project. """
|
| |
Partly fixes #2485.
I added the sqlalchemy validators for the field types for
create new project
.Is it ok like this? (If yes, I'll do the same with
create new issue
and so on.)I had some problems with validating the
create_readme
field => should be boolean. While testing, even when I was passing non boolean value, no exception was raised. Then I figured out, thatcreate_readme
always switches to "False', which then passes as bool. Do you have any idea why this happens or should I investigate more?The rest should be working, but since it's still not finished I was not running the tests.