Can you suggest a more "ember-esque" approach to calculate this value?

Note: Due to my current situation, I must work with Ember 2.18 but I am curious if version ^3.4 has certain features that 2.x does not.

I am creating a Boolean based on the values of two other Booleans. Within the class, the following code snippet is present:

userEmail: '',
feedbackText: '',
emailIsValid: match('useEmail', /^.+@.+\..+$/),
feedbackTextIsValid: gte('feedbackText.length', 5),
disableSubmit: computed('emailIsValid', 'feedbackTextIsValid', function() {
  return (!this.get('emailIsValid') || !this.get('feedbackTextIsValid'));
}),

In simple terms, the disableSubmit property should be true if either userEmail is not a valid email or if feedbackText has less than 5 characters. This functionality works as intended.

My question is whether there exists a method similar to not or match that can return true if either of two other values is not true.

Answer №1

Option 1

If you find yourself limited by the macros available in Ember, another option to consider is utilizing ember-awesome-macros (A widely used library in the Ember community).

disableSubmit: nand('emailIsValid', 'feedbackTextIsValid'), // nand acts like an 'or' with inverted inputs

Option 2

An alternative approach could be combining 'or' and not as shown below.

emailIsNotValid: not('emailIsValid'),
feedbackTextIsNotValid: not('feedbackTextIsValid'),
disableSubmit: or('emailIsNotValid', 'feedbackTextIsNotValid')

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporating Calendar Features into a Traditional .html Website

Currently working on integrating a calendar function into an HTML site. Want to enable my client to easily manage their own calendar by inserting a code snippet from platforms like Google Calendar into a div on the website. As a professional SEO with web ...

The sorting feature for columns seems to be malfunctioning in Bootstrap 5

I have utilized bootstrap 5 to create a table, but I am facing an issue when trying to sort the first column as there is no change reflected. Below is how my table is structured: The structure of the table is as follows: <table class="table" ...

Transferring form data from Jade to Node.js for submission

My Jade template includes the following form structure: form(action='/scheduler/save/' + project.Id, method='post') div.form-group label.control-label.col-md-2 RecurringPattern di ...

Activate the textbox without utilizing `.focus()` method

I am encountering an issue with a small iframe on my page. The content within the iframe is larger than the window itself, requiring users to scroll around to view it in its entirety. Within this iframe, there is a button that, when clicked, triggers an an ...

Error message 'MODULE_NOT_FOUND' occurs while executing a Docker application

Although I successfully created a docker image, I am encountering issues when trying to run it. This is the command that I am using for running: docker run coderpc/test-server Displayed below is the error message that appears in the console. Error: Canno ...

Having trouble updating a MongoDB array through a RESTful API PUT request

I'm brand new to the MEAN stack and recently completed a tutorial. I've been working on enhancing a simple application that utilizes a RESTful API to update a MongoDB. Currently, I'm using a PUT statement to modify specific parts of my colle ...

difficulty encountered when passing parameters in functions such as setInterval

Hi everyone, I need some help with my code. Feel free to check it out here Currently, I'm working on implementing multiple circular progress bars that can function dynamically. The goal is to be able to add additional progressCircle_# objects with di ...

Extract branch, path, and URL from the .gitmodules file by utilizing JavaScript Regex

Is there a way to extract branch, path, and URL details from the .gitmodules file using JavaScript Regex? .gitmodules [submodule "PATH"] path = <PATH> url = <URL> [submodule "PATH"] path = <PATH> url = <URL> ...

Tips for inserting a DIV and SCRIPT from a single HTML template into a webpage

I'm working with an HTML template that contains a DIV with a button and a script with a function to call when the button is clicked: <div id="CLC_Form"> various text and checkbox inputs go here... <br> <input type="button" ...

The $or operator in mongoose falls short in providing complete data when paired with the find() method

I am currently utilizing the find method in conjunction with the $or operator to search the database for any duplicate data within this specific line. const duplicate = await NewItemsData.find({ $or: newItems }); Upon inspecting the variable in the consol ...

The troubleshooting guide for resolving compatibility issues with a background video across various browsers

Something strange occurred. My background video was functioning properly on all browsers until this morning. However, it suddenly stopped working on certain browsers. The video either does not play or freezes immediately. I tried clearing my cache, rever ...

Can you explain what findDOMNode is and why it is no longer supported in StrictMode within the console?

I attempted to create a count-up feature using React visibility sensor and React count up, but encountered an error in the console. Is there a correct solution to this issue? Caution: The use of findDOMNode is deprecated in StrictMode. This method was uti ...

What is the best way to retrieve data from ng-controller to use in the 'src' attribute of an <img> tag?

Check out this snippet of HTML: <div data-ng-controller="sampleCtrl" > <ul data-ng-repeat="item in sampleData"> <li class="message"> <img src="img-source" width="30" height="30"> <div class="message-text"> ...

Error encountered: jquery form validation fails to register changes

I am currently developing a calculator-like code where users will submit a form multiple times, and I need to save the result of calculations only if there are changes in the form. For instance, when a user clicks the "Calculate" button for the first time, ...

How can I stop a hyperlink from activating Jquery?

A script was created to highlight any <TR> element when a user clicks on it, and it is functioning correctly. <script> $(document).ready(function () { $(document).on('click', 'tbody tr', function (e) { ...

VueJS method for making an HTTP GET request

Attempting to make an http get request using Vue js. I can't seem to find any issues with the logic, although I'm not very experienced with vuejs. Continuously encountering these two errors: [Vue warn]: Error in mounted hook: "TypeError: Cann ...

Change / swap Safari website address

Why is it that I can't seem to figure this out? (I have a feeling the solution will be obvious once someone posts an answer) I've been struggling to redirect a user after they click on Logout (It seems like it should be straightforward). However ...

Error Encountered: Module 'openpgp' Not Found

Currently, I am in the process of learning javascript and experimenting with importing modules using npm in my js files. So far, I have been able to successfully import modules using require(), however, I encountered a problem with openpgp.js which resulte ...

most efficient method for verifying if three text fields have no content

Is there a way to verify that the sum of the values in three textboxes is greater than a blank value? <asp:TextBox ID="tbDate" runat="server"></asp:TextBox> <asp:TextBox ID="tbHour" runat="server"></asp:TextBox> <asp ...

How can I create a cube with complete beveling using Three.js?

I'm struggling to create a beveled cube in my project. I have come across the THREE.ExtrudeGeometry snippet in the documentation here. However, when I tried it out, I only managed to achieve beveled sides on the top and bottom faces like this: https: ...