<commit_before>package org.hibernate.validator.spec.s2.s4;

import javax.validation.ConstraintContext;
import javax.validation.Constraint;

/**
 * Check that a string length is between min and max
 * Error messages are using either key:
 *  - error.length.min if the min limit is reached
 *  - error.length.max if the max limit is reached
 */
public class FineGrainedLengthConstraint implements Constraint<Length> {
    private int min;
    private int max;

    /**
     * Configure the constraint validator based on the elements
     * specified at the time it was defined.
     * @param constraint the constraint definition
     */
    public void initialize(Length constraint) {
        min = constraint.min();
        max = constraint.max();
    }

    /**
     * Validate a specified value.
     * returns false if the specified value does not conform to the definition
     * @exception IllegalArgumentException if the object is not of type String
     */
    public boolean isValid(Object value, ConstraintContext constraintContext) {
        if ( value == null ) return true;
        if ( !( value instanceof String ) ) {
            throw new IllegalArgumentException("Expected String type");
        }
        String string = (String) value;
        int length = string.length();

		//remove default error
		constraintContext.disableDefaultError();

		if (length < min) {
			//add min specific error
			constraintContext.addError( "{error.length.min}" );
			return false;
		}
		if (length > max) {
			//add max specific error
			constraintContext.addError( "{error.length.max}" );
			return false;
		}
		return true;
    }
}<commit_msg>typos<commit_after>package org.hibernate.validator.spec.s2.s4;

import javax.validation.ConstraintContext;
import javax.validation.Constraint;

/**
 * Check that a string length is between min and max
 * Error messages are using either key:
 *  - constraint.length.min if the min limit is reached
 *  - constraint.length.max if the max limit is reached
 */
public class FineGrainedLengthConstraint implements Constraint<Length> {
    private int min;
    private int max;

    /**
     * Configure the constraint validator based on the elements
     * specified at the time it was defined.
     * @param constraint the constraint definition
     */
    public void initialize(Length constraint) {
        min = constraint.min();
        max = constraint.max();
    }

    /**
     * Validate a specified value.
     * returns false if the specified value does not conform to the definition
     * @exception IllegalArgumentException if the object is not of type String
     */
    public boolean isValid(Object value, ConstraintContext constraintContext) {
        if ( value == null ) return true;
        if ( !( value instanceof String ) ) {
            throw new IllegalArgumentException("Expected String type");
        }
        String string = (String) value;
        int length = string.length();

		//remove default error
		constraintContext.disableDefaultError();

		if (length < min) {
			//add min specific error
			constraintContext.addError( "{constraint.length.min}" );
			return false;
		}
		if (length > max) {
			//add max specific error
			constraintContext.addError( "{constraint.length.max}" );
			return false;
		}
		return true;
    }
}
{'fraction_non_alphanumeric': 0.08771929824561403, 'fraction_numerical': 0.0012099213551119178, 'mean_word_length': 2.895170789163722, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6821577', 'n_tokens_mistral': 878, 'n_tokens_neox': 832, 'n_words': 312}