original_string: public function validate($value)
      {
          // The value which comes in is a files array so we can look through this
          // to and then get the files to test aspects of them.
          if (isset($value['Files'])) {
              foreach($value['Files'] as $fileID) {
                  $file = File::get()->byId($fileID);
  
                  // Now have the file double-check it is an image and if so then
                  // get some information about the image using PHPs getimagesize()
                  if ($file->ClassName == 'Image') {
                      $info = getimagesize(BASE_PATH . "/" . $file->Filename);
  
                      if ($info && is_array($info)) {
                          $width = $info[0];
                          $height = $info[1];
  
                          switch ($this->type) {
                              case self::WIDTH:
                                  return $width == $this->val1;
                                  break;
                              case self::HEIGHT:
                                  return $height == $this->val1;
                                  break;
                              case self::WIDTH_HEIGHT:
                                  return (($width == $this->val1) && ($height == $this->val2));
                                  break;
                              case self::RATIO:
                                  $baseWidth = floor($width / $this->val1);
                                  $baseHeight = floor($height / $this->val2);
                                  return $baseWidth == $baseHeight;
                                  break;
                              case self::MIN_WIDTH:
                                  return $width >= $this->val1;
                                  break;
                              case self::MIN_HEIGHT:
                                  return $height >= $this->val1;
                                  break;
                              case self::MIN_WIDTH_HEIGHT:
                                  return (($width >= $this->val1) && ($height >= $this->val2));
                                  break;
                              case self::MAX_WIDTH:
                                  return $width <= $this->val1;
                                  break;
                              case self::MAX_HEIGHT:
                                  return $height <= $this->val1;
                                  break;
                              case self::MAX_WIDTH_HEIGHT:
                                  return (($width <= $this->val1) && ($height <= $this->val2));
                                  break;
                              default:
                                  throw new Exception('Invalid type : ' . $this->type);
                          }
                      }
                  }
              }
          } else {
              // Return true so if no file selected then not shown validation message
              // when the field is optional. If required dev should add to required fields as well.
              return true;
          }
      }
code: public function validate($value)
      {
          // The value which comes in is a files array so we can look through this
          // to and then get the files to test aspects of them.
          if (isset($value['Files'])) {
              foreach($value['Files'] as $fileID) {
                  $file = File::get()->byId($fileID);
  
                  // Now have the file double-check it is an image and if so then
                  // get some information about the image using PHPs getimagesize()
                  if ($file->ClassName == 'Image') {
                      $info = getimagesize(BASE_PATH . "/" . $file->Filename);
  
                      if ($info && is_array($info)) {
                          $width = $info[0];
                          $height = $info[1];
  
                          switch ($this->type) {
                              case self::WIDTH:
                                  return $width == $this->val1;
                                  break;
                              case self::HEIGHT:
                                  return $height == $this->val1;
                                  break;
                              case self::WIDTH_HEIGHT:
                                  return (($width == $this->val1) && ($height == $this->val2));
                                  break;
                              case self::RATIO:
                                  $baseWidth = floor($width / $this->val1);
                                  $baseHeight = floor($height / $this->val2);
                                  return $baseWidth == $baseHeight;
                                  break;
                              case self::MIN_WIDTH:
                                  return $width >= $this->val1;
                                  break;
                              case self::MIN_HEIGHT:
                                  return $height >= $this->val1;
                                  break;
                              case self::MIN_WIDTH_HEIGHT:
                                  return (($width >= $this->val1) && ($height >= $this->val2));
                                  break;
                              case self::MAX_WIDTH:
                                  return $width <= $this->val1;
                                  break;
                              case self::MAX_HEIGHT:
                                  return $height <= $this->val1;
                                  break;
                              case self::MAX_WIDTH_HEIGHT:
                                  return (($width <= $this->val1) && ($height <= $this->val2));
                                  break;
                              default:
                                  throw new Exception('Invalid type : ' . $this->type);
                          }
                      }
                  }
              }
          } else {
              // Return true so if no file selected then not shown validation message
              // when the field is optional. If required dev should add to required fields as well.
              return true;
          }
      }
code_tokens: public function validate ( $ value ) { // The value which comes in is a files array so we can look through this // to and then get the files to test aspects of them. if ( isset ( $ value [ 'Files' ] ) ) { foreach ( $ value [ 'Files' ] as $ fileID ) { $ file = File :: get ( ) -> byId ( $ fileID ) ; // Now have the file double-check it is an image and if so then // get some information about the image using PHPs getimagesize() if ( $ file -> ClassName == 'Image' ) { $ info = getimagesize ( BASE_PATH . "/" . $ file -> Filename ) ; if ( $ info && is_array ( $ info ) ) { $ width = $ info [ 0 ] ; $ height = $ info [ 1 ] ; switch ( $ this -> type ) { case self :: WIDTH : return $ width == $ this -> val1 ; break ; case self :: HEIGHT : return $ height == $ this -> val1 ; break ; case self :: WIDTH_HEIGHT : return ( ( $ width == $ this -> val1 ) && ( $ height == $ this -> val2 ) ) ; break ; case self :: RATIO : $ baseWidth = floor ( $ width / $ this -> val1 ) ; $ baseHeight = floor ( $ height / $ this -> val2 ) ; return $ baseWidth == $ baseHeight ; break ; case self :: MIN_WIDTH : return $ width >= $ this -> val1 ; break ; case self :: MIN_HEIGHT : return $ height >= $ this -> val1 ; break ; case self :: MIN_WIDTH_HEIGHT : return ( ( $ width >= $ this -> val1 ) && ( $ height >= $ this -> val2 ) ) ; break ; case self :: MAX_WIDTH : return $ width <= $ this -> val1 ; break ; case self :: MAX_HEIGHT : return $ height <= $ this -> val1 ; break ; case self :: MAX_WIDTH_HEIGHT : return ( ( $ width <= $ this -> val1 ) && ( $ height <= $ this -> val2 ) ) ; break ; default : throw new Exception ( 'Invalid type : ' . $ this -> type ) ; } } } } } else { // Return true so if no file selected then not shown validation message // when the field is optional. If required dev should add to required fields as well. return true ; } }
docstring: Validate function called for validator.
  @param Mixed $value the value of the field being validated.
  @return boolean
docstring_tokens: Validate function called for validator .