<commit_before>package org.geotools.ysld.validate;

import org.geotools.ysld.parse.Util;
import org.opengis.filter.expression.Expression;
import org.opengis.filter.expression.Literal;
import org.yaml.snakeyaml.events.ScalarEvent;

import java.awt.*;

public class ColorValidator extends ScalarValidator {

    @Override
    protected String validate(String value, ScalarEvent evt, YsldValidateContext context) {
        try {
            Expression expr = Util.color(value, context.factory);
            if (expr instanceof Literal) {
                Color col = expr.evaluate(null, Color.class);
                if (col == null) {
                    return "Invalid color, must be one of: 0xrrggbb, rgb(r,g,b), or expression";
                }
            }
            return null;
        }
        catch(Exception e) {
            return e.getMessage();
        }
    }
}
<commit_msg>Updated YSLD error message for invalid color<commit_after>package org.geotools.ysld.validate;

import org.geotools.ysld.parse.Util;
import org.opengis.filter.expression.Expression;
import org.opengis.filter.expression.Literal;
import org.yaml.snakeyaml.events.ScalarEvent;

import java.awt.*;

public class ColorValidator extends ScalarValidator {

    @Override
    protected String validate(String value, ScalarEvent evt, YsldValidateContext context) {
        try {
            Expression expr = Util.color(value, context.factory);
            if (expr instanceof Literal) {
                Color col = expr.evaluate(null, Color.class);
                if (col == null) {
                    return "Invalid color, must be one of: '#RRGGBB', rgb(r,g,b), or expression";
                }
            }
            return null;
        }
        catch(Exception e) {
            return e.getMessage();
        }
    }
}

{'fraction_non_alphanumeric': 0.09657836644591611, 'fraction_numerical': 0.0005518763796909492, 'mean_word_length': 2.2432915921288012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '136194', 'n_tokens_mistral': 510, 'n_tokens_neox': 499, 'n_words': 124}