<?php
/**
* Customizer validation functions
*
* @package Theme Palace
* @subpackage Power News
* @since Power News 1.0.0
*/

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


/*==================Reated Posts===============*/

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