mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
FIX: flatten object value in _cast method
FIX: `mergeObject` to `foundry.utils.mergeObject` FIX: add validateKey
This commit is contained in:
parent
f614456e86
commit
060fe41730
1 changed files with 10 additions and 4 deletions
|
|
@ -17,16 +17,22 @@ export default class ItemLinksField extends foundry.data.fields.TypedObjectField
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
static get _defaults() {
|
static get _defaults() {
|
||||||
return mergeObject(super._defaults, { validateKey: this.validateKey });
|
return foundry.utils.mergeObject(super._defaults, { validateKey: this.validateKey });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} [value] The candidate object to be added.
|
* @param {Object} [value] The candidate object to be added.
|
||||||
*/
|
*/
|
||||||
static validateKey(value) {
|
static validateKey(value) {
|
||||||
return true;
|
|
||||||
const parsed = foundry.utils.parseUuid(value);
|
const parsed = foundry.utils.parseUuid(value);
|
||||||
if (!parsed || parsed.type !== CONFIG.Item.documentClass.documentName) return false;
|
if (!parsed || parsed.type !== foundry.documents.Item.documentName) return false;
|
||||||
if (!foundry.packages.BasePackage.validateId(parsed.documentId)) return false;
|
if (!foundry.data.validators.isValidId(parsed.documentId)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**@inheritdoc */
|
||||||
|
_cast(value) {
|
||||||
|
value = super._cast(value);
|
||||||
|
return foundry.utils.flattenObject(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue