Checking for non-selected object-dropdown

I have a object-dropdown that is loaded with a query and bound to a model. If the user does not select anything from the dropdown, I am throwing an error when trying to write the bound object back to the inserted record. How can I check to see if the dropdown was populated prior to the update?

@mik Do you want to determine if the bound value is populated or if the query has any results to select from?

  1. To determine if a bound value is populated simply check for its presence in JS or make the input required and validate required fields upon the relevant button press.

Sample - checking if something was selected:

<object-dropdown query="some_query_var" bind="some_object_var" />
function checkBoundValue() {
  return !!view.some_object_var // This will return true or false depending on if that variable is populated
}

Sample - make the selection required:

<object-dropdown query="some_query_var" bind="some_object_var" required="true" />
<button label="Proceed" on-press="someFunction" validate="true" />
  1. To determine if a query (or array) has any results to select from, the most efficient option is to check for the presence of the first result in either the query or the array.
  <var name="some_query_var" type="query:some_object" />
  <var name="some_array_var" type="array:some_object" />
function checkQueryHasResults() {
  return (view.some_query_var && !!view.some_query_var.first()) // this will return true or false depending on if the variable exists and if there is at least 1 result in the query
}

function checkArrayHasResults() {
  return (view.some_array_var && !!view.some_array_var[0]) // this will return true or false depending on if the variable exists and if there is at least 1 element in the array
}

I hope this helps