<commit_before>/***
 * Copyright (c) 2009 Caelum - www.caelum.com.br/opensource
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package br.com.caelum.vraptor;

import java.util.Collection;
import java.util.List;

import org.hamcrest.Matcher;

import br.com.caelum.vraptor.validator.Message;

/**
 * A validator interface for VRaptor. It allows you to assert for specific situations.
 *
 * @author <NAME>
 */
public interface Validator {

	/**
	 * Validation based on Hamcrest matcher.
	 * 
	 * @since 4.0.0
	 * @param actual the actual value
	 * @param matcher matcher to test
	 * @param category validation category
	 */
	<T> void check(T actual, Matcher<? super T> matcher, String category);
    
	/**
	 * Validation based on Hamcrest matcher.
	 * 
	 * @since 4.0.0
	 * @param actual the actual value
	 * @param matcher matcher to test
	 * @param category validation category
	 * @param reason
	 */
	<T> void check(T actual, Matcher<? super T> matcher, String category, String reason);
		
	/**
	 * Validation based on Hamcrest matcher.
	 * 
	 * @since 4.0.0
	 * @param actual the actual value
	 * @param matcher matcher to test
	 * @param message {@link Message} object
	 */
	<T> void check(T actual, Matcher<? super T> matcher, Message message);
    
    
    /**
     * Validate an object using some Bean Validation engine. If the object is null,
     * the validation will be skipped.
     *
     * @param object The object to be validated.
     * @param groups The groups to be validated.
     * @since vraptor3.1.2
     */
    void validate(Object object, Class<?>... groups);

    /**
     * Validate the specifics propeties of an object using some Bean Validation engine. If the object is null,
     * the validation will be skipped.
     * 
     * @param object The object to be validated.
     * @param properties The names of properties to be validated.
     */
    void validateProperties(Object object, String... properties);
    
    
	/**
	 * Validate the specific property of an object using some Bean Validation engine. If the object is null, 
	 * the validation will be skipped.
	 * 
	 * @param object The object to be validated.
	 * @param property The name of property to be validated.
	 * @param groups The groups to be validated.
	 */
	void validateProperty(Object object, String property, Class<?>... groups);    

    <T extends View> T onErrorUse(Class<T> view);

    void addAll(Collection<? extends Message> message);

    void add(Message message);

    List<Message> getErrors();

    boolean hasErrors();

    /**<commit_msg>Improving javadocs<commit_after>/***
 * Copyright (c) 2009 Caelum - www.caelum.com.br/opensource
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package br.com.caelum.vraptor;

import java.util.Collection;
import java.util.List;

import org.hamcrest.Matcher;

import br.com.caelum.vraptor.validator.Message;

/**
 * A validator interface for VRaptor. It allows you to assert for specific situations.
 *
 * @author <NAME>
 */
public interface Validator {

	/**
	 * Validation based on Hamcrest matcher.
	 * 
	 * @since 4.0.0
	 * @param actual the actual value
	 * @param matcher matcher to test
	 * @param category validation category
	 */
	<T> void check(T actual, Matcher<? super T> matcher, String category);
    
	/**
	 * Validation based on Hamcrest matcher.
	 * 
	 * @since 4.0.0
	 * @param actual the actual value
	 * @param matcher matcher to test
	 * @param category validation category
	 * @param reason
	 */
	<T> void check(T actual, Matcher<? super T> matcher, String category, String reason);
		
	/**
	 * Validation based on Hamcrest matcher.
	 * 
	 * @since 4.0.0
	 * @param actual the actual value
	 * @param matcher matcher to test
	 * @param message {@link Message} object
	 */
	<T> void check(T actual, Matcher<? super T> matcher, Message message);
    
    
    /**
     * Validate an object using some Bean Validation engine. If the object is null,
     * the validation will be skipped.
     *
     * @param object The object to be validated.
     * @param groups The groups to be validated.
     * @since vraptor3.1.2
     */
    void validate(Object object, Class<?>... groups);

    /**
     * Validate the specifics propeties of an object using some Bean Validation engine. If the object is null,
     * the validation will be skipped.
     * 
     * @param object The object to be validated.
     * @param properties The names of properties to be validated.
     */
    void validateProperties(Object object, String... properties);
    
    
	/**
	 * Validate the specific property of an object using some Bean Validation engine. If the object is null, 
	 * the validation will be skipped.
	 * 
	 * @param object The object to be validated.
	 * @param property The name of property to be validated.
	 * @param groups The groups to be validated.
	 */
	void validateProperty(Object object, String property, Class<?>... groups);    

	/**
	 * If validator has errors, you can use this method to define what to do. WARN: this method don't stop the flow.
	 * @param view
	 * @return
	 */
    <T extends View> T onErrorUse(Class<T> view);

    /**
     * Adds the list of messages.
     * @param messages
     */
    void addAll(Collection<? extends Message> messages);

    /**
     * Adds the message.
     * @param message
     */
    void add(Message message);

    /**
     * Returns a list of errors.
     * @return
     */
    List<Message> getErrors();

    /**
     * Return true if has validation errors. False otherwise.
     * @return
     */
    boolean hasErrors();

    /**
{'fraction_non_alphanumeric': 0.09555388093443859, 'fraction_numerical': 0.006028636021100226, 'mean_word_length': 2.908127208480565, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6743091', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1817, 'n_words': 782}