Validate subject_location preserving last saved value.

        Last valid value of the subject_location field is shown to the user
        for subject location widget to receive valid coordinates on field
        validation errors.
184373
def clean_subject_location(self):
        
        cleaned_data = super(ImageAdminForm, self).clean()
        subject_location = cleaned_data['subject_location']
        if not subject_location:
            # if supplied subject location is empty, do not check it
            return subject_location

        # use thumbnail's helper function to check the format
        coordinates = normalize_subject_location(subject_location)

        if not coordinates:
            err_msg = ugettext_lazy('Invalid subject location format. ')
            err_code = 'invalid_subject_format'

        elif (
            coordinates[0] > self.instance.width
            or coordinates[1] > self.instance.height
        ):
            err_msg = ugettext_lazy(
                'Subject location is outside of the image. ')
            err_code = 'subject_out_of_bounds'
        else:
            return subject_location

        self._set_previous_subject_location(cleaned_data)
        raise forms.ValidationError(
            string_concat(
                err_msg,
                ugettext_lazy('Your input: "{subject_location}". '.format(
                    subject_location=subject_location)),
                'Previous value is restored.'),
            code=err_code)
642353
function _storeDataValidity()
    {
        $record      = 0x01b2;      // Record identifier
        $length      = 0x0012;      // Bytes to follow

        $grbit       = 0x0002;      // Prompt box at cell, no cached validity data at DV records
        $horPos      = 0x00000000;  // Horizontal position of prompt box, if fixed position
        $verPos      = 0x00000000;  // Vertical position of prompt box, if fixed position
        $objId       = 0xffffffff;  // Object identifier of drop down arrow object, or -1 if not visible

        $header      = pack('vv', $record, $length);
        $data        = pack('vVVVV', $grbit, $horPos, $verPos, $objId,
                                     count($this->_dv));
        $this->_append($header.$data);

        $record = 0x01be;              // Record identifier
        foreach ($this->_dv as $dv) {
            $length = strlen($dv);      // Bytes to follow
            $header = pack("vv", $record, $length);
            $this->_append($header . $dv);
        }
    }
338585
V getValidValue() {
            Object v = value;
            if (v == sentinel() || v == BASE_HEADER)
                return null;
            @SuppressWarnings("unchecked") V vv = (V)v;
            return vv;
        }
212343
def last_seen(self):
        """
        These values seem to be rarely updated correctly in the API.
        Don't expect accurate results from this property.
        """
        try:
            if self.side == 'left':
                lastseen = self.device.device_data['leftPresenceEnd']
            elif self.side == 'right':
                lastseen = self.device.device_data['rightPresenceEnd']

            date = datetime.fromtimestamp(int(lastseen)) \
                .strftime('%Y-%m-%dT%H:%M:%S')
            return date
        except TypeError:
            return None
563762
private ValidationResult checkContigLocation(Entry entry) {
		List<Location> locations = entry.getSequence().getContigs();
		Long contigSequenceCoverLength = 0L;
		Long sequenceLength = entry.getSequence().getLength();
		for (Location location : locations) {
			contigSequenceCoverLength += location.getLength();

		}

		if (!sequenceLength.equals(contigSequenceCoverLength)) {

			result.append(EntryValidations.createMessage(entry.getSequence().getContigs()
					.get(0).getOrigin(), Severity.ERROR,
					MESSAGE_ID_INVALID_CONTIG_LOCATIONS,
					contigSequenceCoverLength, sequenceLength));
		}

		return result;
	}
793784
def is_valid(self):
        
        self.errors = []

        for field in self.get_all_field_names_declared_by_user():
            getattr(type(self), field).is_valid(self, type(self), field)
            field_errors = getattr(type(self), field).errors(self)
            self.errors.extend(field_errors)

        return len(self.errors) == 0
1100256
private void validateSubject(final Resource subject) {
        final String subjectURI = subject.getURI();
        // blank nodes are okay
        if (!subject.isAnon()) {
            // hash URIs with the same base as the topic are okay
            final int hashIndex = subjectURI.lastIndexOf("#");
            if (!(hashIndex > 0 && topic.getURI().equals(subjectURI.substring(0, hashIndex)))) {
                // the topic itself is okay
                if (!topic.equals(subject.asNode())) {
                    // it's a bad subject, but it could still be in-domain
                    if (idTranslator.inDomain(subject)) {
                        LOGGER.error("{} is not in the topic of this RDF, which is {}.", subject, topic);
                        throw new IncorrectTripleSubjectException(subject +
                                " is not in the topic of this RDF, which is " + topic);
                    }
                    // it's not even in the right domain!
                    LOGGER.error("subject ({}) is not in repository domain.", subject);
                    throw new OutOfDomainSubjectException(subject.asNode());
                }
            }
        }
    }
425471
def form_valid(self, form):
        # lb = SalesLines.objects.filter(pk=self.__line_pk).first()

        # product_old = lb.product_final
        product_pk = self.request.POST.get("product_final", None)
        quantity = self.request.POST.get("quantity", None)
        product_final = ProductFinal.objects.filter(pk=product_pk).first()
        
        if product_final and quantity:
            reason = form.data['reason']
            if reason:
                reason_obj = ReasonModification.objects.filter(pk=reason).first()
                if reason_obj:
                    try:
                        with transaction.atomic():
                            result = super(LinesUpdateModalBasket, self).form_valid(form)

                            reason_basket = ReasonModificationLineBasket()
                            reason_basket.basket = self.object.basket
                            reason_basket.reason = reason_obj
                            reason_basket.line = self.object
                            reason_basket.user = get_current_user()
                            reason_basket.quantity = self.object.quantity
                            reason_basket.save()
                            return result
                    except ValidationError as e:
                        errors = form._errors.setdefault("product_final", ErrorList())
                        errors.append(e)
                        return super(LinesUpdateModalBasket, self).form_invalid(form)
                else:
                    errors = form._errors.setdefault("reason", ErrorList())
                    errors.append(_("Reason of modification invalid"))
                    return super(LinesUpdatelOrder, self).form_invalid(form)
            else:
                errors = form._errors.setdefault("reason", ErrorList())
                errors.append(_("Reason of modification invalid"))
                return super(LinesUpdatelOrder, self).form_invalid(form)

            """
            if is_pack:
                options = product.productfinals_option.filter(active=True)
                options_pack = []
                for option in options:
                    field = 'packs[{}]'.format(option.pk)
                    opt = self.request.POST.get(field, None)
                    if opt:
                        opt_product = ProductFinal.objects.filter(pk=opt).first()
                        if opt_product:
                            options_pack.append({
                                'product_option': option,
                                'product_final': opt_product,
                                'quantity': quantity
                            })
                        else:
                            errors = form._errors.setdefault(field, ErrorList())
                            errors.append(_("Product Option invalid"))
                            return super(LinesUpdateModalBasket, self).form_invalid(form)
                    else:
                        errors = form._errors.setdefault(field, ErrorList())
                        errors.append(_("Option invalid"))
                        return super(LinesUpdateModalBasket, self).form_invalid(form)
            """
        else:
            errors = form._errors.setdefault("product_final", ErrorList())
            errors.append((_("Product invalid"), quantity, product_final))
            return super(LinesUpdateModalBasket, self).form_invalid(form)

        """
        ret = super(LinesUpdateModalBasket, self).form_valid(form)
        if product_old != self.object.product:
            self.object.remove_options()
        if is_pack:
            self.object.set_options(options_pack)
        return ret
        """
930092
def end_coordsys(self):
        
        coordsys = copy(self.location)
        coordsys.origin = self.end_point
        return coordsys
1021400
public void handleSubmit(VariableScope variableScope, VariableMap values, VariableMap allValues) {
    TypedValue submittedValue = (TypedValue) values.getValueTyped(id);
    values.remove(id);

    // perform validation
    for (FormFieldValidationConstraintHandler validationHandler : validationHandlers) {
      Object value = null;
      if(submittedValue != null) {
        value = submittedValue.getValue();
      }
      validationHandler.validate(value, allValues, this, variableScope);
    }

    // update variable(s)
    TypedValue modelValue = null;
    if (submittedValue != null) {
      if (type != null) {
        modelValue = type.convertToModelValue(submittedValue);
      }
      else {
        modelValue = submittedValue;
      }
    }
    else if (defaultValueExpression != null) {
      final TypedValue expressionValue = Variables.untypedValue(defaultValueExpression.getValue(variableScope));
      if (type != null) {
        // first, need to convert to model value since the default value may be a String Constant specified in the model xml.
        modelValue = type.convertToModelValue(Variables.untypedValue(expressionValue));
      }
      else if (expressionValue != null) {
        modelValue = Variables.stringValue(expressionValue.getValue().toString());
      }
    }

    if (modelValue != null) {
      if (id != null) {
        variableScope.setVariable(id, modelValue);
      }
    }
  }
629673
function( cb ){
              if( ! self.positionField ){
                cb( null );
              } else {

                // If repositioning is required, do it
                if( self.positionField ){
                  var where, beforeId;
                  if( ! options.position ){
                    where = 'end';
                  } else {
                    where = options.position.where;
                    beforeId = options.position.beforeId;
                  }
                  self.reposition( recordWithLookups, where, beforeId, cb );
                }
              }
            }
1239115
def validate(record, field_name, bindings = {})
      if validations
        validations.collect do |validation|
          unless valid_value?(validation, record, field_name, bindings)
            FieldValidationError.new(validation, record, field_name, pos, width)
          end
        end.compact
      elsif record && record[field_name]
        # when no validation rules exist for the field, just check if the field exists in the record
        []
      else
        raise "found field value nil in #{record} field #{field_name}, shouldn't be possible?"
      end
    end
749115
def location_measure_type=(location_measure_type)
      validator = EnumAttributeValidator.new('String', ["Pixels", "Percents", "Millimeters"])
      if location_measure_type.to_i == 0
        unless validator.valid?(location_measure_type)
          raise ArgumentError, "invalid value for 'location_measure_type', must be one of #{validator.allowable_values}."
        end
        @location_measure_type = location_measure_type
      else
        @location_measure_type = validator.allowable_values[location_measure_type.to_i]
      end
    end
1364715
def _is_valid_position(self, position):
        '''
        
        '''
        row, col = position
        valid_r = row in self.row_labels
        valid_c = col in self.col_labels
        return valid_r and valid_c
1357123
def validate_geotweet(self, record):
        
        if record and  self._validate('user', record) \
                and self._validate('coordinates', record):
            return True
        return False
249523
def validate_marked_location(location):
    """"""
    if not isinstance(location, (Location, FoldScopeLocation)):
        raise TypeError(u'Expected Location or FoldScopeLocation location, got: {} {}'.format(
            type(location).__name__, location))

    if location.field is not None:
        raise GraphQLCompilationError(u'Cannot mark location at a field: {}'.format(location))
1055336
function validatePosition(value) {
	if (
		!_.isArray(value) ||
		value.length !== 2 ||
		typeof value[0] !== 'number' ||
		typeof value[1] !== 'number'
	) {
		throw new FieldError('invalid_type', 'Must be array in form [ long, lat ]');
	}
	if (value[0] < -180 || value[0] > 180) {
		throw new FieldError('invalid_format', 'Longitude must be between -180 and 180');
	}
	if (value[1] < -90 || value[1] > 90) {
		throw new FieldError('invalid_format', 'Latitude must be between -90 and 90');
	}
}