from app.main import main
from app.main.utils.common import response_message
from flask import json
from app.rulemall.validators import *


@main.route('/validators', methods=['GET', 'POST'])
def validators():
    vals = []
    for val in [Range, Length, Category, Regex, Missing, Unique, Empty, Logic]:
        v = val()
        vals.append(json.loads(v.__repr__()))
    return response_message(vals)


@main.route('/validators/<val>', methods=['GET', 'POST'])
def get_validator(val):
    dct = {'Range': Range, 'Length': Length, 'Category': Category, 'Regex': Regex, 'Missing': Missing, 'Unique': Unique,
           'Empty': Empty, 'Logic': Logic}
    v = dct[val]()
    return response_message(json.loads(str(v)))


