# Path: diva/exceptions.py
# class ValidationError(Exception):
#     pass


from .exceptions import ValidationError
from flask import render_template
from datetime import date, time, datetime, timedelta
from dateutil.relativedelta import *
from functools import singledispatch
from jsonschema import validate
            'type': 'string',
            'enum': self.choices
        }
        validate(formData, schema)

class SelectSubset(Widget):
    """
    Output: A list of all the strings that the user selection. 
    It may be empty.
    """
    def __init__(self, description, choices, default=[]):
        """
        * choices: a list of strings
        * default: a list of strings in ``choices`` that will be 
            selected by default.
        """
        self.description = description
        self.choices = choices
        self.default = default

    def generateHTML(self, formid):
        return render_template('checklist_widget.html',
                description=self.description,
                choices=self.choices,
                default=self.default)

    def validate_input(self, formData):
        has_duplicates = len(set(formData)) < len(formData)
        is_subset = set(formData).issubset(set(self.choices))
        if has_duplicates or (not is_subset):

# Path: diva/exceptions.py
# class ValidationError(Exception):
#     pass


# Path: diva/widgets.py
from .exceptions import ValidationError
from flask import render_template
from datetime import date, time, datetime, timedelta
from dateutil.relativedelta import *
from functools import singledispatch
from jsonschema import validate

            'type': 'string',
            'enum': self.choices
        }
        validate(formData, schema)

class SelectSubset(Widget):
    """
    Output: A list of all the strings that the user selection. 
    It may be empty.
    """
    def __init__(self, description, choices, default=[]):
        """
        * choices: a list of strings
        * default: a list of strings in ``choices`` that will be 
            selected by default.
        """
        self.description = description
        self.choices = choices
        self.default = default

    def generateHTML(self, formid):
        return render_template('checklist_widget.html',
                description=self.description,
                choices=self.choices,
                default=self.default)

    def validate_input(self, formData):
        has_duplicates = len(set(formData)) < len(formData)
        is_subset = set(formData).issubset(set(self.choices))
        if has_duplicates or (not is_subset):

            raise ValidationError("{} is not a subset of {}", formData, self.choices)