Return True if the media type is a valid form media type.
545
def is_form_media_type(media_type):
    
    base_media_type, params = parse_header(media_type.encode(HTTP_HEADER_ENCODING))
    return (base_media_type == 'application/x-www-form-urlencoded' or
            base_media_type == 'multipart/form-data')
725616
def form_valid(self, form):
        '''  '''
        form.cleaned_data.pop('template', None)
        self.request.session[EMAIL_VALIDATION_STR] = {'form_data': form.cleaned_data}
        return HttpResponseRedirect(reverse('emailConfirmation'))
591231
public static function isValid(string $mediaType): bool
    {
        return (bool) preg_match(self::REGEX, trim($mediaType));
    }
833278
public function validate() {

		$result = parent::validate();

		// Confirm that the current type has been given a title and doesn't already exist.

		if($result->isValid() && !$this->Title) {
			$result->addError('"Title" required!');
		}
		else if($result->isValid() && MediaType::get_one(MediaType::class, array(
			'ID != ?' => $this->ID,
			'Title = ?' => $this->Title
		))) {
			$result->addError('Type already exists!');
		}

		// Allow extension customisation.

		$this->extend('validateMediaType', $result);
		return $result;
	}
782175
def form_valid(self, form):
        
        form.send_email(to=self.to_addr)
        return super(EmailView, self).form_valid(form)
1032233
public boolean mediaIsGIF () {
        String contentType = this.getContentType();
        return contentType != null && this.media != null && contentType.equals("image/gif");
    }
143605
def media_type_str(mediatype):
    """"""
    if mediatype == const.MEDIA_TYPE_UNKNOWN:
        return 'Unknown'
    if mediatype == const.MEDIA_TYPE_VIDEO:
        return 'Video'
    if mediatype == const.MEDIA_TYPE_MUSIC:
        return 'Music'
    if mediatype == const.MEDIA_TYPE_TV:
        return 'TV'
    return 'Unsupported'
1059150
private static void checkMediaType(Multimap<MediaType, SerializationFormat> simplifiedMediaTypeToFormats,
                                       MediaType mediaType) {
        final MediaType simplifiedMediaType = mediaType.withoutParameters();
        for (SerializationFormat format : simplifiedMediaTypeToFormats.get(simplifiedMediaType)) {
            for (MediaType registeredMediaType : format.mediaTypes()) {
                checkState(!registeredMediaType.is(mediaType) && !mediaType.is(registeredMediaType),
                           "media type registered already: ", mediaType);
            }
        }
    }
1145160
def _is_ctype(self, ctype):
        """"""
        if not self.valid:
            return False
        mime = self.content_type
        return self.ContentMimetypes.get(mime) == ctype
936409
protected function validateMimeType () : bool
	{
		if (!is_array($this->allowedMimeTypes) || empty($this->allowedMimeTypes))
			return TRUE;
		if (!in_array($this->mimeType, $this->allowedMimeTypes)):
			$this->error = "Unsupported file type.";
			return FALSE;
		endif;
		return TRUE;
	}
45461
public function isValid() {
		
		$file = $this -> getFile();

		$messages = [

			UPLOAD_ERR_FORM_SIZE 	=> 'File exceeds the maximum file size that was specified in the HTML form',
			UPLOAD_ERR_PARTIAL 		=> 'File was only partially uploaded',
			UPLOAD_ERR_NO_FILE		=> 'No file was uploaded',
			UPLOAD_ERR_NO_TMP_DIR	=> 'Missing a temporary folder',
			UPLOAD_ERR_CANT_WRITE	=> 'Failed to write file to disk',
			UPLOAD_ERR_EXTENSION	=> 'An extension stopped the file upload'
		];

		if(false === isset($messages[$file['error']])) {
			return true;
		}

		$this -> setMessage($messages[$file['error']]);

		return false;
	}
332598
private boolean isImageType(String mime) {
		if (StringUtils.hasText(mime)) {
			for (String imageMime : IMAGE_MIMES) {
				if (mime.equalsIgnoreCase(imageMime)) {
					return true;
				}
			}
		}
		return false;
	}
1325524
def all_valid(formsets):
    """"""
    valid = True
    for formset in formsets:
        if not formset.is_valid():
            valid = False
    return valid
573088
function isImage(file) {
        var valid = true,
          // formats = _module.options.formats || ['csv', 'xls', 'zip', 'kml', 'kmz', 'gpx', 'lut', 'stl', 'dxf', 'txt', 'pdf', 'svg', 'doc', 'ppt', 'gif', 'png', 'jpg', 'jpeg'],
          formats = _module.options.formats || ["gif", "png", "jpg", "jpeg"],
          filetype = file.name.split(".")[file.name.split(".").length - 1];
        filetype = filetype.toLowerCase();
        if (formats.indexOf(filetype) === -1) valid = false;
        return valid;
      }
967334
def form_valid(self, form):
        """"""

        ret = super(ProjectCopy, self).form_valid(form)
        self.copy_relations()

        # Good to make note of that
        messages.add_message(self.request, messages.SUCCESS, 'Project %s copied' % self.object.name)

        return ret
598344
def form_upload_valid(self, form):
        """"""
        self.current_step = self.STEP_LINES

        lines = form.cleaned_data['file']
        initial_lines = [dict(zip(self.get_columns(), line)) for line in lines]
        inner_form = self.get_form(self.get_form_class(),
            data=None,
            files=None,
            initial=initial_lines,
        )
        return self.render_to_response(self.get_context_data(form=inner_form))
928844
protected function validateForm()
    {
        if (2 == $this->currentStep) {
            return true;
        }
        // Note we use an MUtil_Form
        return $this->_form->isValid($this->formData, $this->disableValidatorTranslation);
    }