import DataType from "../DataType";

export default class StringType extends DataType<string>{
    public sanitize(value: any): string|null|undefined {
        if (value === "") return null;
        if (value == null) return value;
        if (typeof value === "number") return '' + value;
        if (typeof value === "boolean") return value ? '1' : '0';
        if (typeof value === "string" ) return value;
        console.warn("Value is not a string");
        console.warn(value);
        throw new Error("Value is not a string");
    }
}