Clarity ClrFormsNextModule *clrIfError Reactive Forms - vmware-clarity

Using Clarity for a work project and I'm unsure if the new clr-control-error messages work with reactive forms. The example they provide on using multiple error messages is with template forms, but the setup should essentially be the same.
Here is my code:
<clr-input-container>
<label>Password</label>
<input clrInput type="password" formControlName="password">
<clr-control-helper>8+ Character Password</clr-control-helper>
<clr-control-error *clrIfError="'required'">Please Enter Password</clr-control-error>
<clr-control-error *clrIfError="'minLength'">Password must be 8+ Characters</clr-control-error>
</clr-input-container>
newCompanyForm = new FormGroup({
email: new FormControl("", [Validators.required]),
password: new FormControl("", [Validators.required, Validators.minLength(8)]),
I'm using #clr/angular v0.12.4, angular 6.0.2, and rxjs 6.1.0. I can see the form is still invalid once I begin to type into the input field, but the error message never switches from "Please Enter Password" to "Password must be 8+ Characters". Once the password reaches 8 characters the field is no longer invalid so I'm pretty sure the Validator is working, just the error message is not showing.

It looks like maxLength and minLength are transformed into maxlength and minlength internally on the errors object. This should fix it below, though I will investigate this and double check it works in both reactive and template-driven forms.
<clr-control-error *clrIfError="'minlength'">

the Inputs Documentation says
Note: the validation only displays an error after the user has left
focus on an input. This is for better UX where the user doesn't see an
error while they are still typing.
This means by design you'll never see error messages while you're typing

Related

Form is submitting empty values though it's required in the datasource (Google App Maker)

Could someone please help me how to display error message when I am submitting form and validating whether all the required fields are filled with data or not in Google App Maker, I have tried by using regular expressions but it didn't work:

How do I fix this code to allow it to compile?

I'm trying to program a script for hubot, and it seems I have an unclosed string. The contents will appear in an html format with emoji like :smile: etc. It isn't compiling in Cofeescript. I'm new to javascript, any help would be appreciated.
The error I got is
ERROR Unable to load /var/discourse/avebot/scripts/test: /var/discourse/avebot/scripts/test.js:5
msg.reply("Hello! I’m Avebot, and I will be your guide throughout your training. :smile: <br>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:51:7)
and the script is:
robot.hear(/hi bot/, function(msg) {
msg.reply("Hello! I’m a bot, and I will be your guide your training. :smile: <br>
<br>After finishing this training, you will be able to do x y z. :tada:<br>
Are you ready? If so, let me know you are ready by replying 'yes I’m ready!'");
//Start a dialog with the user that sent this message.
var dialog = switchBoard.startDialog(msg);
//Provide choices for the next step, wait for the user.
dialog.addChoice(/yes/, function(msg2){ msg2.reply('Okay');}
dialog.addChoice( /no/, function(msg2){ msg2.reply("Okay, I'll wait"); }
//The dialog will expire after 30 secods.
});
You need to escape the ' in I'm Avebot by putting a backslash before the apostrophe (so it's I\'m Avebot).
Check out this site here for more information on JS escape sequences.
in order to define multiline strings in Javascript you can use backslash \ before new lines
msg.reply("Hello! I’m a bot, and I will be your guide your training. :smile: <br>\
<br>After finishing this training, you will be able to do x y z. :tada:<br>\
Are you ready? If so, let me know you are ready by replying 'yes I’m ready!'");

How to simulate onblur event with Robot Framework

I am automating login scenario of an application.
The execution steps are as below:
Select the Country
Enter the Username
Enter the Password
Click on Login Button.
Actually after entered the username, application validates the country and username in database exists or not.
When tried to automate through robot framework, this validation is not called and so unable to login (actually login button is clicked through script, but no error message or no response user is in same page).
When i verified exact scenario it calling the validation, comes to know that
validation is called on onblur of the usename element onblur="getlocation()".
I tried to simulate this by give tabout from username field through script as
Press Key ${element path} \\9 but it is not working always out of 10 run only 3 or 4 times it working.
Is there any way we can do 'blur` action on the element in robot framework
In the Selenium2Library for robot, there is a special keyword for that:
Simulate <element> <event>
In my keyword definition it looks like this:
I Enter The New Password
[Arguments] ${text}
Input Text ${INPUT_ELEMENT_PASSWORD} ${text}
Simulate ${INPUT_ELEMENT_PASSWORD} blur
http://robotframework.org/Selenium2Library/Selenium2Library.html#Simulate
I hope that helps, it took us a while to figure out what was missing in the test.
Just to save few minutes of googling.
Simulate
is deprecated. Use
Simulate Event
instead

Anywhere - Field validation

Working on Work Execution app (v 7.5.2). In MAM, Field having datatype as INTEGER (4) but when I enter values "1234567890123456789' in Anywhere, it doesn't throw error instantly but after saving, It throws "Database error number -4461 has occurred when operating on WORKLOG : WorkLog ID=1234. Report the error to the owner of the deployment."
Either User should warn immediately after entered or Need to restrict the MaxLength to enter in TEXTBOX. How to do ?
You can put some validate javascript code on the dataChange event for this field to validate that less than 4 characters were input. You can also open a PMR as this seems like a limitation that we would address in a future release.

Is this a KnockoutJS bug or am I doing multiple bindings wrong?

I've been working my way through the KnockoutJS documentation and tried to modify example 3 of the "Writeable computed observables" section in this page.
The example basically shows a textbox and displays a message if the user enters a non-numeric value to the textbox. I tried to modify the code so that the textbox has a pink background when the message appears.
The problem is when you enter a invalid value the textbox turns pink as expected but the value you entered is replaced with what was originally there. I have no idea why this behavior is occurring since everything worked fine before I added the style binding to get the pink background. Try removing the style binding and notice how the behavior changes when you enter an invalid value.
What's going on?
The code is below or try out this jsfiddle.
<p>
Enter a numeric value:
<input data-bind="value: attemptedValue
,style: {backgroundColor: lastInputWasValid() ?
'transparent' :
'pink' }"/>
</p>
<div data-bind="visible: !lastInputWasValid()">That's not a number!</div>
function MyViewModel() {
this.acceptedNumericValue = ko.observable(123);
this.lastInputWasValid = ko.observable(true);
this.attemptedValue = ko.computed({
read: this.acceptedNumericValue,
write: function (value) {
if (isNaN(value))
this.lastInputWasValid(false);
else {
this.lastInputWasValid(true);
this.acceptedNumericValue(value); // Write to underlying storage
}
},
owner: this
});
}
ko.applyBindings(new MyViewModel());
EDIT: Here's another fiddle with the style binding removed. Try appending the letter 'a' and taking focus out of the textbox. Notice how the letter 'a' stays there. Try that with the original fiddle textbox and notice how it is removed. The only change between the two fiddles is the presence of the style binding.
If the value is NAN than it is never written to the model, therefore the input will be updated to the existing value of the model when the onblur event is fired.
this.acceptedNumericValue(value); // Write to underlying storage
Is the code that updates when the value is numerical. You can see that it is not in the else block.
So I sent an email to the KnockoutJS user group and got a reply in about 7 hours (not too shabby).
Sadly, Google Groups confuses me and I have no idea how to reply to the fellow who cleared up my question to tell him to come on over here and post his answer so I guess I'll do it for him. All credit goes to John Earles of the KO user group.
It make sense to me.
In your example without the style, Knockout does not have to re-render
your input (only the error), so the value stays the same.
In your example with the style, Knockout does have to re-render your
input (to add the style), so BOTH bindings execute and it reads the
value - which is the last accepted value.
Here is a version that saves the attempted value into one of two
observables, and reads from the appropriate one based on
lastInputWasValid:
http://jsfiddle.net/jearles/VSWfr/

Resources