Custom attribute writer method with validation
 @param [Object] note Value to be assigned
179661
def note=(note)

      if !note.nil? && note.to_s.length > 60
        fail ArgumentError, "invalid value for 'note', the character length must be smaller than or equal to 60."
      end

      @note = note
    end
359911
def validate
      xsd = Nokogiri::XML::Schema(File.read(SCHEMA_FILE))
      out = ""
      xsd.validate(@report).each do |error|
        out << error.message unless error.message == "Element 'algorithm', attribute 'publication_ref': '' is not a valid value of the atomic type 'xs:IDREF'." || error.message == "Element 'descriptor', attribute 'publication_ref': '' is not a valid value of the atomic type 'xs:IDREF'." 
        # @todo ignore case sensitivity error: error.message The value 'NO' is not an.Element of the set {'Yes', 'No'}.
      end
      return out
    end
828823
function(model, value, attr) {
      var indices, validators,
        validations = model.validation ? _.result(model, 'validation') || {} : {};
      // If the validations hash contains an entry for the attr
      if (_.contains(_.keys(validations), attr)) {
        return validateAttrWithOpenArray(model, attr, value, _.extend({}, model.attributes));
      } else {
        indices = extractIndices(attr);
        attr = stripIndices(attr);
        validators = getValidators(model, attr);
        return invokeValidator(validators, model, value, attr, _.extend({}, model.attributes), indices);
      }
    }
54948
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:magicnumber"})
	public void writeRecord(AttributeProvider element) throws IOException, AttributeException {

		if (this.columns == null) {
			throw new MustCallWriteHeaderFunctionException();
		}

		//Field deleted flag (value : 2Ah (*) => Record is deleted, 20h (blank) => Record is valid)
		this.stream.writeByte(0x20);

		for (final DBaseFileField field : this.columns) {
			// Get attribute
			final DBaseFieldType dbftype = field.getType();
			final String fieldName = field.getName();

			AttributeValue attr = element != null ? element.getAttribute(fieldName) : null;

			if (attr == null) {
				attr = new AttributeValueImpl(dbftype.toAttributeType());
				attr.setToDefault();
			} else {
				if (attr.isAssigned()) {
					attr = new AttributeValueImpl(attr);
					attr.cast(dbftype.toAttributeType());
				} else {
					attr = new AttributeValueImpl(attr);
					attr.setToDefaultIfUninitialized();
				}
			}

			// Write value
			switch (dbftype) {
			case BOOLEAN:
				writeDBFBoolean(attr.getBoolean());
				break;
			case DATE:
				writeDBFDate(attr.getDate());
				break;
			case STRING:
				writeDBFString(attr.getString(), field.getLength(), (byte) ' ');
				break;
			case INTEGER_2BYTES:
				writeDBFInteger((short) attr.getInteger());
				break;
			case INTEGER_4BYTES:
				writeDBFLong((int) attr.getInteger());
				break;
			case DOUBLE:
				writeDBFDouble(attr.getReal());
				break;
			case FLOATING_NUMBER:
			case NUMBER:
				if (attr.getType() == AttributeType.REAL) {
					writeDBFNumber(attr.getReal(), field.getLength(), field.getDecimalPointPosition());
				} else {
					writeDBFNumber(attr.getInteger(), field.getLength(), field.getDecimalPointPosition());
				}
				break;
			case BINARY:
			case GENERAL:
			case MEMORY:
			case PICTURE:
			case VARIABLE:
				// not yet supported
				writeDBFString((String) null, 10, (byte) 0);
				break;
			default:
				throw new IllegalStateException();
			}
		}

		// Be sure that the memory was not fully filled by the saving process
		if (element != null) {
			element.freeMemory();
		}
	}
719368
def input=(input)
      validator = EnumAttributeValidator.new('String', ["html", "xml", "auto"])
      unless validator.valid?(input)
        fail ArgumentError, "invalid value for 'input', must be one of #{validator.allowable_values}."
      end
      @input = input
    end
1100861
def _FormatNotes(self, event):
    
    inode = event.inode
    if inode is None:
      inode = '-'

    notes = getattr(event, 'notes', '')
    if not notes:
      display_name = getattr(event, 'display_name', '')
      notes = 'File: {0:s} inode: {1!s}'.format(display_name, inode)
    return self._SanitizeField(notes)
486900
def is_valid_note(note):
    """"""
    if not _note_dict.has_key(note[0]):
        return False
    for post in note[1:]:
        if post != 'b' and post != '#':
            return False
    return True
1140581
def fieldsets
        content = ''
        each_with_rescue(@notes) do |note|
          next unless note.has_fieldset?
          content << <<-HTML
            <fieldset id="#{note.to_sym}_debug_info" style="display: none">
              <legend>#{note.legend}</legend>
              <div>#{note.content}</div>
            </fieldset>
          HTML
        end
        content
      end
983475
def attachment_attributes_valid?
        [:size, :content_type].each do |attr_name|
          enum = attachment_options[attr_name]
          errors.add attr_name, I18n.translate("activerecord.errors.messages.inclusion", attr_name => enum) unless enum.nil? || enum.include?(send(attr_name))
        end
      end
753982
def note(id, type, options = {})
      # Welguisz:  No idea why this is here, but keeping it here because it follows other blocks
      _notes
      # Create a new note and place it in the notes 2-D Hash
      @_notes[id][type] = Note.new(id, type, options)
    end
107871
def set_evernote_spec():
        
        spec = NoteStore.NotesMetadataResultSpec()
        spec.includeTitle = True
        spec.includeAttributes = True
        return spec
1152503
function (notes, settings) {
  var restBuffer = 0;

  var events = _.reduce(notes, function (arr, obj) {
    var time = noteLength(obj.duration, settings);

    if (obj.note) {
      arr.push(makeNoteEvent(restBuffer, true, 0, noteValue(obj.note), settings.noteVelocity)); // On
      arr.push(makeNoteEvent(time, false, 0, noteValue(obj.note), settings.noteVelocity)); // Off
      restBuffer = 0;
    }
    else {
      restBuffer += time;
    }

    return arr;
  }, []);

  return Buffer.concat(events);
}
696404
function(model, attr) {
      var attrValidationSet = model.validation ? _.result(model, 'validation')[attr] || {} : {};

      // If the validator is a function or a string, wrap it in a function validator
      if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) {
        attrValidationSet = {
          fn: attrValidationSet
        };
      }

      // Stick the validator object into an array
      if(!_.isArray(attrValidationSet)) {
        attrValidationSet = [attrValidationSet];
      }

      // Reduces the array of validators into a new array with objects
      // with a validation method to call, the value to validate against
      // and the specified error message, if any
      return _.reduce(attrValidationSet, function(memo, attrValidation) {
        _.each(_.without(_.keys(attrValidation), 'msg', 'msgKey'), function(validator) {
          memo.push({
            fn: defaultValidators[validator],
            val: attrValidation[validator],
            msg: attrValidation.msg,
            msgKey: attrValidation.msgKey
          });
        });
        return memo;
      }, []);
    }
822088
def check_note(note, chord):
    
    if note not in NOTE_VAL_DICT:
        raise ValueError("Invalid chord {}: Unknown note {}".format(chord, note))
    return True
1353860
def required_attributes
      validators.map{ |v| v.attributes if v.is_a?(Mongoid::Validations::PresenceValidator) }.flatten.compact
    end
849707
function Note(obj){
    this._id = obj && obj.id;
    this._modifiedAt = obj && obj.modifiedAt;
    this._content = obj && obj.content;
}
274459
def attributes= (attrs)
      attrs.each_pair do |name, value|
        field = schema.fields[name.to_s] || FieldDefinition.new(name, :type => value.class)
        setter = "#{name}=".to_sym
        if respond_to?(setter)
          send(setter, value)
        else
          write_attribute(field, value, self)
        end
      end
    end