If you are adding a bag info tag with a lot of text and this text contains at least one colon on "right" place the validation of created bag is failing. Look into this example program:
use \whikloj\BagItTools\Bag;
$dir = __DIR__ . "/newbag";
// Create new bag as directory $dir
$bag = Bag::create($dir);
// set extended on true calculate oxum value
$bag->setExtended(true);
$bag->addBagInfoTag('Title', 'A really long long long long long long long long long long long title with a colon : between and more information are on the way');
$bag->update();
if (!$bag->validate()) {
echo 'Validation error!' . PHP_EOL;
foreach ($bag->getErrors() as $number => $reason) {
echo $reason['file'] . ': ' . $reason['message'] . PHP_EOL;
}
} else {
echo 'Bag successful validated' . PHP_EOL;
}
Output is:
Validation error!
bag-info.txt: Labels cannot begin or end with a whitespace. (Line 2)
Content of bag-info.txt is:
Title: A really long long long long long long long long long long long title
with a colon : between and more information are on the way
Payload-Oxum: 0.0
Bagging-Date: 2020-09-28
If you are adding a bag info tag with a lot of text and this text contains at least one colon on "right" place the validation of created bag is failing. Look into this example program:
Output is:
Content of bag-info.txt is: