package kotowari.data;

import enkan.collection.Multimap;
import enkan.data.Extendable;
import enkan.util.ThreadingUtils;

import java.util.List;

/**
 * @author kawasima
 */
public interface Validatable extends Extendable {
    default boolean hasErrors() {
        Multimap<String, String> errors = (Multimap<String, String>) getExtension("errors");
        if (errors != null) {
            return !errors.isEmpty();
        }
        return false;
    }

    default boolean hasErrors(String key) {
        return ThreadingUtils.some((Multimap<String, String>) getExtension("errors"),
                errors -> errors.getAll(key),
                List::isEmpty).orElse(false);
    }

    default List<String> getErrors(String key) {
        return getErrors().getAll(key);
    }

    default Multimap<String, String> getErrors() {
        return (Multimap<String, String>) getExtension("errors");
    }

    default void setErrors(Multimap<String, String> errors) {
        setExtension("errors", errors);
    }
}

@@ -648,21 +648,35 @@
     
-List::
+errors -%3E !errors.
 isEmpty
+()
 ).or

Fixed the problem where isEmpty method is isNotEmpty