Display an error if trying to save custom attributes with dot notation

This commit is contained in:
Andrew 2019-11-20 20:45:33 -08:00
parent 96b677434b
commit be0c47da58
2 changed files with 2 additions and 0 deletions

View file

@ -120,6 +120,7 @@ export class SimpleActorSheet extends ActorSheet {
const formAttrs = expandObject(formData).data.attributes || {}; const formAttrs = expandObject(formData).data.attributes || {};
const attributes = Object.values(formAttrs).reduce((obj, v) => { const attributes = Object.values(formAttrs).reduce((obj, v) => {
let k = v["key"].trim(); let k = v["key"].trim();
if ( /[\s\.]/.test(k) ) return ui.notifications.error("Attribute keys may not contain spaces or periods");
delete v["key"]; delete v["key"];
obj[k] = v; obj[k] = v;
return obj; return obj;

View file

@ -104,6 +104,7 @@ export class SimpleItemSheet extends ItemSheet {
const formAttrs = expandObject(formData).data.attributes || {}; const formAttrs = expandObject(formData).data.attributes || {};
const attributes = Object.values(formAttrs).reduce((obj, v) => { const attributes = Object.values(formAttrs).reduce((obj, v) => {
let k = v["key"].trim(); let k = v["key"].trim();
if ( /[\s\.]/.test(k) ) return ui.notifications.error("Attribute keys may not contain spaces or periods");
delete v["key"]; delete v["key"];
obj[k] = v; obj[k] = v;
return obj; return obj;