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


@main.route('/validators', methods=['GET', 'POST'])
def validators():
    vals = []
    for val in [Range, Length, Category, Regex, Missing, Unique, Empty]:
        v = val()
        vals.append(json.loads(str(v)))
    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}
    v = dct[val]()
    return response_message(json.loads(str(v)))


