package com.imprimelibros.erp.common;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.jsoup.Jsoup;
import org.jsoup.safety.Safelist;

@Converter(autoApply = false)
public class HtmlStripConverter implements AttributeConverter<String, String> {

    @Override
    public String convertToDatabaseColumn(String attribute) {
        return attribute == null ? null : Jsoup.clean(attribute, Safelist.none());
    }

    @Override
    public String convertToEntityAttribute(String dbData) {
        return dbData; // tal cual
    }
}
