<?php
/**
 * Validation functions
 *
 * @package Corporaze_Pro
 */

if ( ! function_exists( 'corporaze_validate_excerpt_length' ) ) :
	function corporaze_validate_excerpt_length( $validity, $value ) {
		$value = intval( $value );
		if ( empty( $value ) || ! is_numeric( $value ) ) {
			$validity->add( 'required', esc_html__( 'You must supply a valid number.', 'corporaze' ) );
		} elseif ( $value < 1 ) {
			$validity->add( 'min_no_of_words', esc_html__( 'Minimum no of words is 1', 'corporaze' ) );
		} elseif ( $value > 200 ) {
			$validity->add( 'max_no_of_words', esc_html__( 'Maximum no of words is 200', 'corporaze' ) );
		}
		return $validity;
	}
endif;

if ( ! function_exists( 'corporaze_validate_blog_count' ) ) :
	function corporaze_validate_blog_count( $validity, $value ) {
		$value = intval( $value );
		if ( empty( $value ) || ! is_numeric( $value ) ) {
			$validity->add( 'required', esc_html__( 'You must supply a valid number.', 'corporaze' ) );
		} elseif ( $value < 1 ) {
			$validity->add( 'min_no_of_posts', esc_html__( 'Minimum no of posts is 1', 'corporaze' ) );
		} elseif ( $value > 6 ) {
			$validity->add( 'max_no_of_posts', esc_html__( 'Maximum no of posts is 6', 'corporaze' ) );
		}
		return $validity;
	}
endif;
