AnsPress_Validation::validate( string $field, array $actions )

Description #

Validate a field based on actions passed

Parameters #

  • $field
    string (Required)
  • $actions
    array (Required)

Changelog #

VersionDescription
2.0.1Introduced.

Source #

File: includes/class/validation.php

	private function validate($field, $actions) {

		foreach ( $actions as $type => $param ) {
			if ( isset( $this->errors[$field] ) ) {
				return; }

			switch ( $type ) {
				case 'required':
					$this->required( $field );
					break;

				case 'length_check':
					$this->length_check( $field, $param );
					break;

				case 'comma_separted_count':
					$this->comma_separted_count( $field, $param );
					break;

				case 'is_email':
					$this->is_email( $field );
					break;

				default:
					$this->errors[$field] = apply_filters( 'ap_validation_validate_field', $field, $actions );
					break;
			}
		}
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment