TagDefinition

TagDefinition

TagDefinition describes the name of a tag, which tag file it should appear in, what its allowed values are, and more.

TagDefinitions belong to the BagItProfile object.

Constructor

new TagDefinition(opts)

Parameters:
Name Type Description
opts object

Values to copy into TagDefinition properties. The properties of this object match the properties of the TagDefinition class, which are described below.

Source:
See:

Members

defaultValue :string

The default value for this tag. This is the value that will be assigned to the tag when you create a bag and don't specify a value for this tag. For example, if you set the default value of the 'Source-Organization' tag, you'll never have to set that value again when building individual bags (unless you want to). The bagger will simply fill in the default. The userValue property, if non-empty, will override defaultValue during the bagging process.

Source:
See:
  • userValue

errors :Object.<string, string>

Contains information describing validation errors. Key is the name of the invalid field. Value is a description of why the field is not valid.

Source:

help :string

Help describes the significance of this tag to end users. In the DART UI, it appears as a tooltip to help the user fill in a meaningful value.

Source:

id :string

The unique identifier for this TagDefinition. This is a version 4 UUID in hex string format.

Source:

isBuiltIn :boolean

The isBuiltIn flag is true for built-in tags whose definition should not be altered or even changeable by the user. For example, the BagIt-Version and Tag-File-Character-Encoding tags in the bagit.txt file are builtins whose value the user can edit, and whose definition they cannot alter.

Source:

isUserAddedFile :boolean

isUserAddedFile is a special flag indicating the user added this custom tag file, which is not part of the standard BagIt profile. The DART UI handles these files differently from those that are part of a core BagItProfile.

Source:

isUserAddedTag :boolean

isUserAddedTag describes whether this tag was added by the user (and hence is not part of the standard BagIt profile upon which the bag is built). Users may add custom tags to standard tag files (such as bag-info.txt) or to their own custom tag files. All tags in custom tag files will have isUserAddedTag = true.

Source:

required :boolean

True if this tag requires a value.

Default Value:
  • false
Source:

tagFile :string

The name of the tag file in which this tag is expected to appear.

Source:

tagName :string

The name of the tag. For example, 'Source-Organization'.

Source:

userValue :string

A user-defined value to assign to this tag when creating a bag. If this value is non-empty, it overrides defaultValue. You will always want to set this on a per-bag basis for certain tags, such as 'Title', 'Description', or any other bag-specific tag.

Source:
See:
  • defaultValue

values :Array.<string>

A list of valid values for this tag. If this list is empty, then any values are valid. If it is not empty, the BagIt validator will check to ensure that any values assigned to this tag are in the list. If they're not, the validator will reject the bag as invalid.

Source:

wasAddedForJob

wasAddedForJob will be true if the user added this custom tag from the jobs UI. This means it's a job-specific tag and the user should be able to delete it without breaking the bag's conformity to a profile.

Source:

Methods

(static) fromCommandLineArg(str) → {TagDefinition}

Given a tag string in command-line format, this returns a new TagDefinition object.

Parameters:
Name Type Description
str string

A tag definition string in command-line format, which is filename/tagname: value. For example, call with param 'bag-info/Source-Organization: Faber College' would return a new TagDefinition object with the properties tagFile = 'bag-info.txt', tagName = 'Souce-Organization', userValue = 'Faber College'.

Source:

getValue() → {string}

Returns this tag's userValue, if that's non-empty, or its defaultValue.

Source:

looksLikeDescriptionTag() → {boolean}

Returns true if the tag name contains the word 'description'.

Source:

systemMustSet() → {Array.<string>}

Returns true if the system, and not the user, must set this value. The system sets certain values, such as Bagging-Date, internally when it creates the bag.

Source:
See:

toFormattedString() → {string}

toFormattedString returns the tag as string in a format suitable for writing to a tag file. Following LOC's bagit.py, this function does not break lines into 79 character chunks. It prints the whole tag on a single line, replacing newlines with spaces.

Source:

validate() → {boolean}

validate returns true or false, indicating whether this object contains complete and valid data. If it returns false, check the errors property for specific errors.

Source:

validateForJob() → {Array.<string>}

This returns a list of errors describing what's wrong with the tag's value. For example, if a tag value is empty when empty values are not allowed, or if the value is not in the tag's list of valid values.

Source: