You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more like a 🤔 , since I solved how to get around it. I tried very hard to tweak the demo twiddle to reproduce this, but it just keeps crashing for different reasons.
I have a data structure of Texts, and each Text has multiple Entrys [sic]. Now, since each Text has different requirements of its Entrys, the model has an array, entryProperties, that looks like, say, this:
so since the validation scheme of an Entry's properties object is set at the Text level, I can't write a fixed Validations file in app/validations or whatever. Here's where things get weird...
In the component setting up the form, this works fine:
// inside a Component definitiongetEntryValidations(){return{name: validatePresence(true),"properties.page": validateNumber(true),"properties.speaker": validatePresence(true)};}
And then even this works fine:
// inside a Component definitiongetEntryValidations(){constvalidations={name: validatePresence(true)};[{name: "page",type: "number"},{name: "speaker",type: "string"}].forEach(prop=>{if(prop.type==="number"){validations[`properties.${prop.name}`]=validateNumber(true);}else{validations[`properties.${prop.name}`]=validatePresence(true);}returnvalidations;}
But this causes any number of problems, most notably that the "name" <input> wouldn't even update when I type in it. Here I'm passing a Text in as this.args.model:
// inside a Component definitiongetEntryValidations(){constvalidations={name: validatePresence(true)};this.args.model.entryProperties.forEach(prop=>{if(prop.type==="number"){validations[`properties.${prop.name}`]=validateNumber(true);}else{validations[`properties.${prop.name}`]=validatePresence(true);}returnvalidations;}
In the console, the validations object would look identical to the previous examples, but it just caused chaos. No amount of .toArray() or [ ...this.args.model.entryProperties] inside the get EntryValidations() would fix it. Finally, on a lark, I tried this, and it worked:
// inside a Component definitionentryProperties=this.args.model.entryProperties.toArray();getEntryValidations(){constvalidations={name: validatePresence(true)};this.entryProperties.forEach(prop=>{if(prop.type==="number"){validations[`properties.${prop.name}`]=validateNumber(true);}else{validations[`properties.${prop.name}`]=validatePresence(true);}returnvalidations;}
All is good, but this seems like a weird hiccup?
The text was updated successfully, but these errors were encountered:
This is more like a 🤔 , since I solved how to get around it. I tried very hard to tweak the demo twiddle to reproduce this, but it just keeps crashing for different reasons.
I have a data structure of
Text
s, and eachText
has multipleEntry
s [sic]. Now, since eachText
has different requirements of itsEntry
s, the model has an array,entryProperties
, that looks like, say, this:These all get saved under the umbrella of
properties
in theEntry
model, so a typicalEntry
will look something like this:so since the validation scheme of an
Entry
'sproperties
object is set at theText
level, I can't write a fixed Validations file inapp/validations
or whatever. Here's where things get weird...In the component setting up the form, this works fine:
And then even this works fine:
But this causes any number of problems, most notably that the "name"
<input>
wouldn't even update when I type in it. Here I'm passing aText
in asthis.args.model
:In the console, the validations object would look identical to the previous examples, but it just caused chaos. No amount of
.toArray()
or[ ...this.args.model.entryProperties]
inside theget EntryValidations()
would fix it. Finally, on a lark, I tried this, and it worked:All is good, but this seems like a weird hiccup?
The text was updated successfully, but these errors were encountered: