"""
JSON schema for users.

:copyright: Copyright 2013-2017, Dorian Pula <dorian.pula@amber-penguin-software.ca>
:license: AGPL v3+
"""


from rookeries.users import models

USER_CREATION_MODIFICATION_SCHEMA = {
    'type': 'object',
    'required': ['username', 'password'],
    'properties': {
        'username': {
            'type': 'string',
            'minLength': 1,
            'maxLength': 64,
        },
        'password': {
            'type': 'string',
            'minLength': 8,
        },
        'role': {
            'type': 'string',
            'enum': [role.name for role in models.UserRole],
        },
        'profile': {
            'type': 'object',
            'properties': {
                'aliasName': {'type': 'string'},
                'fullName': {'type': 'string'},
                'email': {
                    'type': 'string',
                    'format': 'email',
                },
            }
        }
    }
}
