<commit_before><?php defined( 'ABSPATH' ) or die();

/**
 * Performs the input validation
 *
 * Uses Valitron to validate form
 * If form validates, an action is triggered
 *
 * @since 0.2.0
 * @since 0.6.0 renamed from Form_Validate_Post
 */
class WFV_Validate {

  /**
   * Form identifier
   *
   * @since 0.1.0
   * @access protected
   * @var string $action
   */
  protected $action;

  /**
   * Validation rules
   *
   * @since 0.1.0
   * @access protected
   * @var array $rules Form validation rules.
   */
  protected $rules = array();

  /**
   * Error message overrides
   *
   * @since 0.4.0
   * @access protected
   * @var array $messages The field/rule paired messages.
   */
  protected $messages = array();

  /**
   * User input from failed validation
   *
   * @since 0.2.1
   * @access protected
   * @var array $input Form validation rules.
   */
  protected $input = array();

  /**
   * Result from wp_nonce_field()
   *
   * @since 0.3.0
   * @access protected
   * @var string $nonce_field WP rendered nonce field.
   */
  protected $nonce_field;

  /**
   * Error message bag
   *
   * @since 0.6.1
   * @access protected
   * @var array Error messages for fields.
   */
  protected $errors;


  /**
   * __construct
   *
   * @since 0.2.0
   * @param Object $form The validation properties
   *
   */
  function __construct() {

  }

  /**
   * Do the validation
   *
   * @since 0.2.0
   * @since 0.6.0 Public access
   */
  public function validate() {
    $this->validate_nonce();
    $v = $this->create_valitron();

    if ( $v->validate() ) {
      do_action( $this->action, $this->input );
    } else {
      $this->errors = $v->errors();
    }
  }

  /**<commit_msg>new getter methods to retrieve property values<commit_after><?php defined( 'ABSPATH' ) or die();

/**
 * Performs the input validation
 *
 * Uses Valitron to validate form
 * If form validates, an action is triggered
 *
 * @since 0.2.0
 * @since 0.6.0 renamed from Form_Validate_Post
 */
class WFV_Validate {

  /**
   * Form identifier
   *
   * @since 0.1.0
   * @access protected
   * @var string $action
   */
  protected $action;

  /**
   * Validation rules
   *
   * @since 0.1.0
   * @access protected
   * @var array $rules Form validation rules.
   */
  protected $rules = array();

  /**
   * Error message overrides
   *
   * @since 0.4.0
   * @access protected
   * @var array $messages The field/rule paired messages.
   */
  protected $messages = array();

  /**
   * User input from failed validation
   *
   * @since 0.2.1
   * @access protected
   * @var array $input Form validation rules.
   */
  protected $input = array();

  /**
   * Result from wp_nonce_field()
   *
   * @since 0.3.0
   * @access protected
   * @var string $nonce_field WP rendered nonce field.
   */
  protected $nonce_field;

  /**
   * Error message bag
   *
   * @since 0.6.1
   * @access protected
   * @var array Error messages for fields.
   */
  protected $errors;


  /**
   * __construct
   *
   * @since 0.2.0
   * @param Object $form The validation properties
   *
   */
  function __construct() {

  }

  /**
   * Return property value
   *
   * @since 0.6.1
   * @param string $property Property key name
   *
   * @return mixed Property value
   */
  public function get( $property ) {
    return $this->$property;
  }

  /**
   * Return field value from $input property
   *
   * @since 0.6.1
   * @param string $field Name of field
   *
   * @return string Field value
   */
  public function get_input( $field ) {
    return $this->input[ $field ];
  }

  public function get_error( $field ) {
    return $this->errors[$field];
  }

  /**
   * Do the validation
   *
   * @since 0.2.0
   * @since 0.6.0 Public access
   */
  public function validate() {
    $this->validate_nonce();
    $v = $this->create_valitron();

    if ( $v->validate() ) {
      do_action( $this->action, $this->input );
    } else {
      $this->errors = $v->errors();
    }
  }

  /**
{'fraction_non_alphanumeric': 0.13922457200402819, 'fraction_numerical': 0.01812688821752266, 'mean_word_length': 2.264585045193098, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '1512365', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1326, 'n_words': 370}