# Path: rest_api_framework/models/validators.py
# class IntegerValidator(Validator):
#     """
#     Validate that a value is of type int
#     """
# 
#     def validate(self, field):
#         """
#         Check if field is an instance of type 'int'
#         """
#         if isinstance(field, int):
#             return True
#         return False
# 
# class StringValidator(Validator):
#     """
#     Validate that a value is of type basestring (either str or unicode)
#     """
# 
#     def validate(self, field):
#         if isinstance(field, basestring):
#             return True
#         return False
# 
# class FloatValidator(Validator):
#     """
#     Validate that a value is of float type
#     """
# 
#     def validate(self, field):
#         if isinstance(field, float):
#             return True
#         return False
# 
# class SQLiteForeign(Validator):
#     """
#     Validate that the foreign row exists
#     """
#     need_datastore = True
# 
#     def __init__(self, **options):
#         self.options = options
# 
#     def validate(self, field, datastore):
# 
#         cursor = datastore.conn.cursor()
# 
#         cursor.execute("SELECT * FROM sqlite_master WHERE type='table';")
#         # cursor = datastore.conn.cursor()
#         query = "SELECT {0} FROM {1} WHERE {2}=?".format(
#             self.options["foreign"]["column"],
#             self.options["foreign"]["table"],
#             self.options["foreign"]["column"],
#         )
#         cursor.execute(query, (field, ))
#         if cursor.fetchone():
#             return True
#         return False


from abc import ABCMeta
from .validators import (IntegerValidator, StringValidator,
                         FloatValidator, SQLiteForeign)
    def __init__(self, name, **options):
        self.validators = [SQLiteForeign(**options), IntegerValidator()]
        super(ForeignKeyField, self).__init__(name, **options)


class IntForeign(ForeignKeyField, Field):
    """
    A type of integer and a Foreign key to check
    """
    base_type = "integer"
    example = 42


class StringForeingKey(ForeignKeyField, Field):
    """
    A type of string and a Foreign key to check
    """
    base_type = "string"
    example = "hackme"

    def __init__(self, name, **options):
        super(StringForeingKey, self).__init__(name, **options)
        self.validators = [SQLiteForeign(**options), StringValidator()]


class StringPkField(PkField):
    """
    A string based PkField
    """
    base_type = "string"

# Path: rest_api_framework/models/validators.py
# class IntegerValidator(Validator):
#     """
#     Validate that a value is of type int
#     """
# 
#     def validate(self, field):
#         """
#         Check if field is an instance of type 'int'
#         """
#         if isinstance(field, int):
#             return True
#         return False
# 
# class StringValidator(Validator):
#     """
#     Validate that a value is of type basestring (either str or unicode)
#     """
# 
#     def validate(self, field):
#         if isinstance(field, basestring):
#             return True
#         return False
# 
# class FloatValidator(Validator):
#     """
#     Validate that a value is of float type
#     """
# 
#     def validate(self, field):
#         if isinstance(field, float):
#             return True
#         return False
# 
# class SQLiteForeign(Validator):
#     """
#     Validate that the foreign row exists
#     """
#     need_datastore = True
# 
#     def __init__(self, **options):
#         self.options = options
# 
#     def validate(self, field, datastore):
# 
#         cursor = datastore.conn.cursor()
# 
#         cursor.execute("SELECT * FROM sqlite_master WHERE type='table';")
#         # cursor = datastore.conn.cursor()
#         query = "SELECT {0} FROM {1} WHERE {2}=?".format(
#             self.options["foreign"]["column"],
#             self.options["foreign"]["table"],
#             self.options["foreign"]["column"],
#         )
#         cursor.execute(query, (field, ))
#         if cursor.fetchone():
#             return True
#         return False


# Path: rest_api_framework/models/fields.py
from abc import ABCMeta
from .validators import (IntegerValidator, StringValidator,
                         FloatValidator, SQLiteForeign)

    def __init__(self, name, **options):
        self.validators = [SQLiteForeign(**options), IntegerValidator()]
        super(ForeignKeyField, self).__init__(name, **options)


class IntForeign(ForeignKeyField, Field):
    """
    A type of integer and a Foreign key to check
    """
    base_type = "integer"
    example = 42


class StringForeingKey(ForeignKeyField, Field):
    """
    A type of string and a Foreign key to check
    """
    base_type = "string"
    example = "hackme"

    def __init__(self, name, **options):
        super(StringForeingKey, self).__init__(name, **options)
        self.validators = [SQLiteForeign(**options), StringValidator()]


class StringPkField(PkField):
    """
    A string based PkField
    """
    base_type = "string"

    validators = [StringValidator()]