Formatter trim in expression [repeat1[0].text1.value.trim() === ""] doesn't exist for type string

I have a flow running based on the condition that the input value should not be empty. However, I’m not able to execute this flow properly due to this error. How can I correct this?

Can you please paste the exact expression you are using and explain what are you trying to achieve?

I have a repeating text input binded to a datastore. I want to add new values to the datastore through the text input on click of the “Add new tower” button. However, I want don’t want those values to be empty before adding to the datastore.

Add-input-to datastore

Here’s the code I have for that:

<dmx-datastore id="datastore1"></dmx-datastore>
<div class="container">
	<div class="row">
		<div class="col">
			<h1 class="mt-4 mb-4">Map Towers &amp; Wings</h1>
		</div>
	</div>
	<div class="row">
		<div class="col-6">

			<div dmx-repeat:repeat1="datastore1.data">
				<input name="text1" type="text" class="form-control rounded-0 " dmx-bind:value="Tower" dmx-style="">


			</div>

			<button id="btn1" class="btn w-100 btn-primary rounded-0"
				dmx-on:click="run({condition:{if:`repeat1[0].text1.value.trim() === &quot;&quot;`,then:{steps:{run:{action:`text1.focus()`}}},else:{steps:{run:{action:`datastore1.insert({Tower: repeat1[0].text1.value})`}}}}})">+ Add New
				Tower</button>


		</div>

What exactly are you trying to achieve with:

repeat1[0].text1.value.trim() === &quot;&quot;

And why is this text input supposed to do in the repeat? It’s not really clear what is your idea.

Removed the text input from the repeat. This is what I want to achieve, but I don’t want the user to be able to push empty or whitespace string into the datastore

Can you just use a ‘Required’ validation on the form field?

Yeah that does Brad. Thank you… I complicated that too much I feel stupid for that now…

However, still curious though why the trim function doesn’t work…

1 Like

Haha … glad it’s working for you now though. :beers: