I am currently working on MEAN stack using node, express and angularjs. I downloaded boiler plate code from mean.io and also using debugger while I explore the code.
In the controller which gets req and res as parameters, how does req.assert work?
In the file server/controllers/users.js
req.assert('username', 'Username cannot be more than 20 characters').len(1,20);
adds into validation error even when the username is empty or null. How do I check for current username value in the req? Where is the assert function of req defined.
I come from java background and find it tricky to find the function code some times as I wont be sure about where is it defined and how is it prototyped. How does one properly read the objects and browse the functions that are being used in javascript?
It's defined in Express's dependency express-validator. Check here: https://github.com/ctavan/express-validator/blob/master/lib/express_validator.js
which depends on validator:
https://github.com/chriso/validator.js
Accepted answer refers to what is now the Legacy API hence broken links.
Check out the documentation for Sanitization and the available sanitizing tools. You can make custom validators in there.
Related
I have done a microsoft tutorial called Web API with Javascript
I now have a UI made with Javascript and HTML which looks like this:
How do I use the UI? I keep getting a Reference Error. Is there a specific syntax I am supposed to follow when I add and edit something via APIs?
In the future, please copy and paste error messages into your question. I would normally copy and paste the error message in my answer, but I don't want to type it all out :)
The errors (red) mean that you're trying to use JavaScript that is not defined yet. The warnings (yellow) are the reason why.
The second warning says that it could not load the JavaScript. That explains the errors. The first warning might be the reason why. It's saying that the MIME type is empty, when it should be application/javascript.
But you said in the comments that the site.js file is empty when you try to access it directly. Did you save all the JavaScript in step 4 of that tutorial to site.js?
And what are you using as a web server? IIS Express?
I'm trying to read sell offers from this exchange called Liquid using Ruby's Pusher library. For some reason everything else in the documentation is in Ruby, except for the Pusher part which is in Javascript. Link to the documentation
I read Ruby's Pusher documentation and they simply don't really go well together. They don't use the same variables and I'm totally lost.
This is what I have so far and am kind of stuck. Even this is pretty much a guess.
require 'pusher'
taptoliq('price_ladders_cash_btcusd_sell')
def taptoliq(path=nil)
channels_client = Pusher::Client.new(
key: 'LIQUID',
channel: path,
event: 'updated',
host: 'tap.liquid.com',
wsHost: 'tap.liquid.com',
)
PUSHER_URL = 'The example code doesnt have secrets, apps or app ids. The command below doesnt run without this being configured correctly.'
channels_client = Pusher::Client.from_env
end
I want to have a variable that would dynamically update. I'm not sure if my channel_client is configured correctly and I'm more than sure that PUSHER_URL is wrong as well. The final command of the function is what crashes complaining bad configurations.
"Uncaught exception: C:/rubyproj/liquidtap.rb:10: dynamic constant assignment"
The PUSHER_URL should not be defined in your code but as environment variable, as you assign this String to the constant, you get this error. It hould be in the form http://KEY:SECRET#HOST/apps/APP_ID
The .from_env reads this environment variable.
Environment variables are set differently depending in your operating system.
I am following below walkthrough by J. Lattimar to add Documents navigation in CRM form tab. It was working fine in classical forms, but for unified forms the steps are not working and instead throw exception like An Error as has occurred. Any idea how to get this working?
https://jlattimer.blogspot.com/2017/01/show-sharepoint-documents-on-main-form.html
Xrm.Page is deprecated, so you'll need to update this JS. Start here:
https://learn.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming
First of all, this is unsupported approach we are following, author clearly called it out.
In UCI why it broke - someone did investigation already
Replacing Xrm.Page.context.getQueryStringParameters().etc
with "10069" ended up resolving this and currently works within UCI and Classic interfaces.
Actually couple of things to take care.
Like Hoffma said - Xrm.Page is deprecated, you have to rewrite the code to refer formContext from executionContext
Xrm.Page.context.getQueryStringParameters() is not containing the etc now, that's why breaking in UCI. You can supply the entity type code (etc) in the url manually
I have run into an issue that I believe is rooted in the implementation of anchor tags in Rhino. Although I am utilizing env.js, I suspect perhaps I am not configuring something correctly.
In particular, my issue occurs while I am attempting to write unit tests against code written for an angularjs application. When I include angular.js (versions 1.2.1 to present), I get the following error:
TypeError: Cannot call method "charAt" of undefined
I am convinced the error is the result of this call to urlParsingNode.pathname since a console.log call reveals that the pathname object is undefined.
I traced the instantiation of the urlParsingNode to this line where we see that it is the result of a call to document.createElement("a"); Further down, we see that they set the href attribute in this line in hopes that the created anchor tag will utilize the browser to correctly parse the URL.
I have to believe I'm not the first to attempt JS unit testing for angular via Rhino, but thus far I've not successfully Googled myself to a solution. Any tips will be greatly appreciated.
Found it and fixed it. The pathname getter/setter simply was undefined for HTMLAnchorElement in env.js.
I submitted a pull request, but unfortunately the project looks all but abandoned. I also couldn't figure out how to build it out to a single file. It appears perhaps someone has taken it upon themselves to break it apart into require.js modules. Not a battle worth fighting for my use case.
So for anyone else who hits this issue, I have the code you need below. It belongs in the HTMLAnchorElement.prototype. In my copy of env.js 1.2, this prototype begins on line 8075. I added the following at line 8118.
get pathname() {
var uri = Envjs.urlsplit(this.href);
return uri.path;
},
set pathname(val) {
var uri = Envjs.urlsplit(this.href);
uri.path = val
this.href(uri.urlunsplit(uri));
},
FYI, my particular issue is resolved with this pull request.
Ok, Im trying to rebuild a clients website thats long over due for cleanup on the backend and under the hood. This client uses flowplayer for most of the videos seen on any of there sites, and while attempting to validate my code via w3c validator I notice that the validator is throwing 2 errors both pertaining to flowplayer in this case.
http://validator.w3.org/check?uri=http%3A%2F%2Fv2.newyorkbarshow.com%2Fhome&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.3
I am using the latest flowplayer out, and following there example (which I don't know if that validates either). So I am wondering if it doesn't validate out of the box, if anyone happens to know a means of correcting it so it will validate.
You need to add data attribute with value "/static/imgs/static/VidAd4BarShow.swf" in your object tag.
note : I see this happens before flow player executes anything within your source...