Check that all files have the allowed type.

@param int $value Draft item id with the uploaded files.
@return string|null Validation error message or null.
19287
public function validateSubmitValue($value) {

        if (empty($value)) {
            return;
        }

        $filetypesutil = new \core_form\filetypes_util();
        $whitelist = $filetypesutil->normalize_file_types($this->_options['accepted_types']);

        if (empty($whitelist) || $whitelist === ['*']) {
            // Any file type is allowed, nothing to check here.
            return;
        }

        $draftfiles = file_get_all_files_in_draftarea($value);
        $wrongfiles = array();

        if (empty($draftfiles)) {
            // No file uploaded, nothing to check here.
            return;
        }

        foreach ($draftfiles as $file) {
            if (!$filetypesutil->is_allowed_file_type($file->filename, $whitelist)) {
                $wrongfiles[] = $file->filename;
            }
        }

        if ($wrongfiles) {
            $a = array(
                'whitelist' => implode(', ', $whitelist),
                'wrongfiles' => implode(', ', $wrongfiles),
            );
            return get_string('err_wrongfileextension', 'core_form', $a);
        }

        return;
    }
1090488
private function getValueType($value)
	{
		if (is_numeric($value)) {
			return Type::NUMBER;
		}

		if (is_array($value)) {
			return Type::STRING_SET;
		}

		return Type::STRING;
	}
719075
public static function typeOfValue($value)
    {
        if (is_null($value)) {
            return self::TYPE_NULL;
        }
        if (is_int($value)) {
            return self::TYPE_INT;
        }
        if (is_bool($value)) {
            return self::TYPE_BOOL;
        }
        return self::TYPE_STR;
    }
5120
private function isValidType($value): bool
    {
        if ($this->type instanceof DataType) {
            return $this->type->isTheTypeOf($value);
        }

        return true;
    }
261786
public function isValueValid($value) {
		return $value instanceof Type\QualitativeValue || $value instanceof DataType\TextType || $value instanceof DataType\URLType;
	}
100398
protected function determineType($type, $value)
    {
        foreach ((array) $type as $t) {
            if ($t == 'string' && (is_string($value) || (is_object($value) && method_exists($value, '__toString')))) {
                return 'string';
            } elseif ($t == 'object' && (is_array($value) || is_object($value))) {
                return 'object';
            } elseif ($t == 'array' && is_array($value)) {
                return 'array';
            } elseif ($t == 'integer' && is_integer($value)) {
                return 'integer';
            } elseif ($t == 'boolean' && is_bool($value)) {
                return 'boolean';
            } elseif ($t == 'number' && is_numeric($value)) {
                return 'number';
            } elseif ($t == 'numeric' && is_numeric($value)) {
                return 'numeric';
            } elseif ($t == 'null' && !$value) {
                return 'null';
            } elseif ($t == 'any') {
                return 'any';
            }
        }

        return false;
    }
510605
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($this->value, self::$sourceList);
    }
1270191
private function checkPartMatchingType($value, $type)
    {
        switch ($type) {
            case "digit":
                return ctype_digit($value);
                break;

            case "hex":
                return ctype_xdigit($value);
                break;

            case "alpha":
                return ctype_alpha($value);
                break;

            case "alphanum":
                return ctype_alnum($value);
                break;

            default:
                return false;
        }
    }
768680
public function isUploadArray($value) {
		if (!is_array($value)) {
			return false;
		}
		$requiredKeys = ['name', 'type', 'tmp_name', 'error', 'size'];
		$keys = array_keys($value);
		foreach ($requiredKeys as $key) {
			if (!in_array($key, $keys)) {
				return false;
			}
		}

		return true;
	}
63333
public function isValueValid($value) {
		return $value instanceof Type\DataFeedItem || $value instanceof DataType\TextType || $value instanceof Type\Thing;
	}
1060467
public function isValueValid($value) {
		return $value instanceof Type\ListItemType || $value instanceof DataType\TextType || $value instanceof Type\ThingType;
	}
552033
protected function typecast($value)
    {
        if ($value === '' && $this->type !== Schema::TYPE_STRING) {
            return null;
        }
        if ($value === null || gettype($value) === $this->phpType || $value instanceof Expression) {
            return $value;
        }
        switch ($this->phpType) {
            case 'resource':
            case 'string':
                return is_resource($value) ? $value : (string) $value;
            case 'int':
            case 'integer':
                return (int) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'double':
                return (double) $value;
        }

        return $value;
    }
1102362
private function getPdoDataType($value)
	{
		$result = \PDO::PARAM_STR;

		if (is_bool($value)) {
			$result = \PDO::PARAM_BOOL;
		} elseif (is_null($value)) {
			$result = \PDO::PARAM_NULL;
		} elseif (is_int($value)) {
			$result = \PDO::PARAM_INT;
		}

		return $result;
	}
239392
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($this->value, self::$statusList);
    }
11088
public function transform($value)
    {
        if (is_array($value)) {
            $value = $value[FileType::UPLOAD_FIELDNAME];
        }

        try {
            return array(
                FileType::UPLOAD_FIELDNAME => new File(call_user_func($this->callback, $value, $this->property))
            );
        } catch (FileNotFoundException $e) {
            return null;
        }
    }
1179696
public function isValueValid($value) {
		return $value instanceof Type\GeoShapeType || $value instanceof Type\PlaceType || $value instanceof DataType\TextType;
	}
841241
public function isValueValid($value) {
		return $value instanceof Type\PlaceType || $value instanceof Type\PostalAddressType || $value instanceof DataType\URLType;
	}