« first day (3019 days earlier)      last day (1934 days later) » 

12:41 AM
@TobiasK write an example with React Router
$$$$_profit_$$$
 
 
3 hours later…
3:16 AM
Hi,
Is any setting to make the `npm audit fix` automatically run after each installation if there are vulnerabilities?

Everytime I install new package I need type this command to clear the warnings. Or did I get something wrong in my package.json so the warning just keep popped? (I'm new to javascript)
 
Hi!, this is probably a lame question but i can't get my head around this. anyone could help to to access this JSON obj?
 
@RodrigoRamírez Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
{"BDT_KHR":{"2019-01-07":47.842028}} , i want to access 47.84
 
!!> (obj = {"BDT_KHR":{"2019-01-07":47.842028}}, obj["BDT_KHR"]["2019-01-07"])
 
@david 47.842028
 
3:24 AM
@RodrigoRamírez obj["BDT_KHR"]["2019-01-07"] will give it to you
 
thanks! i will try it
 
3:39 AM
thanks @david !!
it work like a champ
 
building this form
 
 
1 hour later…
5:05 AM
 
 
2 hours later…
7:05 AM
@Baldráni keh
 
interesting ...comic?
 
7:38 AM
calling xkcd as a comic is an insult I think 😲
 
Which plugins do you use in vscode for react and es6 ?
 
Not any one
I am that guy that prefers to have an IDE / editor with few plugins as possible
 
7:58 AM
HARK! THE CLIFFS!
 
 
1 hour later…
9:10 AM
@jAndy The Game :)
 
Hey, does anyone know if it's a wise move to ask questions about my own code as a question on the main site by sharing my GitHub repo rather than just segments of code? The regular updating of the question post to clarify it can be quite taxing and the person's recommended solution might not be working since it is only certain parts of ur package that you are showing
 
@PrashinJeevaganth Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@SomeGuy I love you too
 
<3
@PrashinJeevaganth In general, you want to minimize the problem to a smaller reproducable sample - sharing the entire thing is okay, but you're not particularly likely to get responses if it's your entire project you're sharing
Also, it's better for questions/answers to be self-contained
 
oh so it's like if you think a problem lies in a certain segment of code and decide to show only those segment in an official question, it is possible someone suggests a fix, but the fix doesnt work because maybe there is some underlying flaw in ur project that he doesnt know of.

Do you mean that supplementing GitHub repo along with the segments in the question from the start isn't going to get responses?
 
9:16 AM
as said earlier provide a code snippet of the area of concern and then a link to the full code
you can add some pseudo code as well to give perspective on areas no shown in the snippet of code
 
@PrashinJeevaganth In general, I'd recommed building minimal reproducable samples. Some guidance that StackOverflow provides on this: stackoverflow.com/help/mcve
 
I have a dilemma for a project right now(just learnt the basic tools for development so not a professional). I have a version of a project that is working but hasn't implemented all required features. Another version only available in my local machine that has produced some bugs and still work in progress on trying to create the feature. I want to push my code(the work in progress one with bugs) onto GitHub and share it for people to give some feedback on where the bug could go wrong.
But I'm not sure what commands is there to reverse the push in the event I wish to scrape my current implementation of the new feature and start from scratch.
 
You could branch off before committing your WIP feature
If you'd rather keep one branch, you can always git revert commits too
 
I meant pushing to GitHub, not committing(whose changes stays only in the current branch only until it is pushed by my understanding), like pushing is sort of permanent and I dont really know the command of how to get back the entire previous version of code after I pushed the bugged version.
When one clones a repository, they only clone the latest version but not any of the older versions right?
 
before you push to github, you need to commit
 
9:26 AM
Github is a "remote" git server. You can't push to a remote without committing locally
 
instead of github you could just use jsfiddle OR codepen
 
yes I know that
 
You can revert your commit or rebase (and remove it from the history entirely) and then force push to Github
 
the magic of git is that you can go back as much as you want
 
But if you're uncomfortable with git, be careful
 
9:27 AM
with the magical git reset
 
git gud
 
@PrashinJeevaganth They clone everything usually
 
first off, I'd recommend you learn how to use git commands, there is actually a great visual tutorial for that which I recommend for everyone, lemme find a link
^ is amazing
will teach you the basics and the more advanced stuff too, while keeping it simple and understandable.
 
Cool resource!
 
i see the benefits of git but if you are trying to do some troubleshooting on your code its just not as user friendly as other options
 
9:31 AM
@HelloWorldPeace Depends - these days with projects always having built steps, sometimes a git repo's way easier than anything else
 
@SomeGuy Do you mean if I have version 1 and version 2(buggy), in the event I pushed version 2, then if I want to get back version 1, I should just run git revert on my local machine to get version 1 and repush, that way my new history of git will be version 1, version 2, version 1?
 
@PrashinJeevaganth Close enough to that, yeah.
If you want to erase all trace of version 2 having existed, you can rebase to rewrite history
 
@SomeGuy you mean the outcome for this turns out to be just version 1, as if I never did a commit and revert consecutively?
 
pretty much, if you do it correctly
 
Yeah. I'm not sure if Github still stores it, though (different remotes act differently for force pushes - for eg. Gitlab will store it still and let you access it in the UI separately from the branch by calling it a "version", if it was part of a merge request, but it drops it if it was just a generic push
 
9:35 AM
there is also things that make sure the version gets entirely wiped from existence
with stuff like filter-branch
 
anyone familiar with the minimax algorithm?
 
anyways, the way I recommend you approach this is:
1. Make a commit with v1
 
maximize your reward, minimize your opponnent's reward
 
2. Make a feature branch
commit your new buggy code to feature branch
in the future, you can just drop it and leave it be, or if yuo really dont want it, wipe the branch
from that point forward you can do all kinds of stuff with merges, rebases, cherry-picking and many more
 
@Neoares have you ever built any application using minimax?
 
9:38 AM
hm... no
but why would I do that in javascript?
 
web application
 
Node js is the powerhouse of the cell
 
are you running the algorithm in the client?
 
@HelloWorldPeace that DOES NOT sound like something that should EVER exist on a frontend
 
I was thinking of this.

1)Start with a master branch
2)Make feature branch and end up developing and committing buggy code(v2)
3)Make a 2nd feature branch with the old unaltered master branch(v1 in another branch)
4)Merge buggy with master and push the commits to GitHub(currently version 2)
5)Now v1 exists in another branch in case I screw up the revert?
 
9:40 AM
yes its for a board game
 
I mean since you are starting out and don't have that much experience with git
I'd say go ahead if you want to make a backup branch
but normally there is no need
unless you somehow wipe your master
 
well if it's a simple minimax you can do it in the client
 
dude
if somebody plays a game
and a game does calc on frontend
it can be altered
 
its just for learning purposes at the moment
 
maybe it's just an experiment, not something serious
like a demo
see?
 
9:44 AM
exactly
lots of spaghetti code at the moment
 
the board changes
 
what do you mean
the code for the AI has issues. towards the end of the game it starts missing winning moves
 
Zee
10:15 AM
Hi could anyone help me out?#
 
!!welcome Zee
 
@Zee Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
Zee
I'm building a film review site with PouchDB & JS but there's 2 things I want to do, and I can't seem to figure them out
Thanks Neil
 
not familiar with PouchDB, but if the question is sufficiently vague, maybe I can help :)
 
Zee
1. I currently have JS pulling the image for the film onto the main page, I want to basically do the overlay hover effect, but also pull the title of the film from the database to only show on hover
 
10:20 AM
hmm, ok
 
that means whenever you hover, you're not going to have the image right away
so you'll have to show a loading icon or something
 
Zee
What do you mean?
 
you either preload or there will be a short delay before they can see the image
 
Zee
It's currently the image that you can see
it's the text that I want to show on hover
 
10:22 AM
if you already have the image, why wouldn't you have the title?
I'd think you'd delay the loading of the image if anything
 
Zee
okay well that one isn't TOO important, that was just for a little extra flair
the second one is the one that matters most
 
you're on a page showing several movies, right? I assume you have some information regarding each movie
 
Zee
Well, the way I'm planning on doing it, is just showing an image for each movie, then when the movie is clicked it goes onto its own separate page
but from some of the cover arts it may not be 100% apparent what the film is, so I figured the title on hover would be cool
 
when you fetch the movie image, fetch also the title
no need to make that a separate request
then you can show it when the user hovers above it
 
Zee
so, going from:
let image = '<a class="btn" href="viewFilm.html?id=' + thisFilm._id +'"><img class="filmImage" src="' + thisFilm.image +'"></a>';


listContents += '<div class="filmRow">'+ image + '</div>';
 
10:26 AM
thisFilm.title :)
 
Zee
just add the title?
 
well the server has to send it of course
but yeah
 
Zee
Oh, I've been thinking it's some whole convoluted process
 
Add a hidden div where the title would be
then change css rules so that when user hovers above it, it'll fade in
or at least, that's how I'd do it
I'd still make clicking on it go to its own page
or you could create an overlay showing that same information without changing page
but that would require an ajax request to grab all the details
it would look nice though
 
Zee
Yeah I'd like a hover popup in reality, but I don't have that kind of time nor knowledge right now, so it'll have to go on the backburner for now
does this look about right?
        listContents += '<div class="filmRow">'+ image + '</div><div class="hiddenText">' + thisFilm.title + '</div>'
 
10:31 AM
why don't you put that in the <div> itself?
and try to work with objects:
let div = document.createElement('div');
div.classList.add('filmRow');
div.dataset.title(thisFilm.title);
// assume listContents is an array now, not string
listContents.push(div);
 
Zee
let me try that
 
I agree, it is generally nicer to not try to "generate" html and add it to the page
you could also add the html to the page and leave it hidden, then use it as a sort of template, changing the pieces you need and copying it
this lets you effectively reduce your javascript part to simply assigning the dynamic parts
 
Zee
Yeah that's a good point, I'll bare that in mind for the future
Okay second issue
 
user986408
dumb question:
i got a queue/worker pattern and two functions, one is populating the queue and one is running a consumer and processing the jobs.
now i'd like to return a promise in the populating function when the given job is done, but the worker logic is as described in another function.
is there any way i can link this?
 
@codepushr Call .then()?
 
10:43 AM
does that not defeat the purpose of the queue?
 
Zee
I currently have a sort by ID ascending/descending function, but I also want to be able to filter the films by genre (action, comedy, horror, other) so that when the genre is selected, the other film posters are hidden, but I have 0 clue how to go about doing that
 
If you must do something only after it has been populated
 
user986408
@KarelG kind of, the worker should process the things on its own, i know
but i need to give the caller some kind of feedback for further processing logic
 
you should work with events
 
user986408
any references?
 
10:45 AM
!! mdn custom events
but that is not in sync (event handling is still async)
 
user986408
that should be fine
 
user986408
i'll look into it, thanks
 
!!> 1+1
 
@KarelG 2
 
mdn command not fixed it seems
 
10:47 AM
you added an unnnecessary space
!!mdn karel
 
a right
 
@Neoares That didn't make much sense. Maybe you meant: 3, am, u, d, y, !, ^, π, ?, א
 
!!mdn object
 
!!mdn custom event
 
nevermind
 
10:47 AM
sorry
 
user986408
is caprica six some kind of grandmother of all chatbots?
 
she's the metachatbot
Creator of all Bots
fisrt on her name
 
user986408
hehe
 
Zee
      let db = new PouchDB('films');

      let radios = document.getElementsByName("sort");
      radios[0].addEventListener("change", getFilmList);
      radios[1].addEventListener("change", getFilmList);

      getFilmList();

      function getFilmList(){
        db.allDocs({include_docs: true, descending: radios[0].checked}).then(function(films){

          let listContents = '';


          for(let i = 0; i < films.total_rows; i++) {
            let thisFilm = films.rows[i].doc;
            let image = '<a class="btn" href="viewFilm.html?id=' + thisFilm._id +'"><img class="filmImage" 
 
@codepushr someone came up with an idea to work out a chatbot for SO chat. It works purely on javascript and became an inspiration for those other bots in another rooms
 
10:50 AM
she's the seed
 
Zee
how would i go about making a filter by genre? :3
 
use .filter( foo => condition)
 
Zee
foo?
 
unless you are fetching from the db. add a filter in your query then
 
baby don't bar me
 
Zee
10:52 AM
yeah i'm fetching from db
 
write another function that selects the films only by genre and use that selector
so function getFilmListByGenre(genreName) (or genreId, depends of your db setup)
 
Zee
Okay thanks for your help @Karel
you too @Neil
 
no problemo
 
11:11 AM
@Zee still a tip: only return objects from database, not html stuff
with this, you can reuse the db function for other stuff
 
user986408
@KarelG thanks bud, working now using EventEmitter and job.id matching
 
user986408
wrapped everything up into a sweet promise for the populating function
 
12:30 PM
Does anyone here know of a .promisify style function that will allow a nodeback style function to either take a callback, or return a Promise if a callback wasn't supplied? All the ones I can find only support full Promise-mode operation.
 
@Alnitak just check if the argument was passed. if it isn't, return a promise
if it is, call it.
 
I know I can do that, but I'm trying to port a large application piece-meal from nodeback style to Promise style
and don't want to write a wrapper for every existing function, nor re-invent the wheel if someone else already did this.
 
hmm, well if you're not returning promises now, the only feasible way of adapting a callback function is to pass an "adapter" callback
but you can't do that, because you may conceivably be returning a promise
I don't think it's possible, but I've been surprised before
 
I don't mind doing exports.myfunc = function(..., cb) { } .mangle()
I just don't want to write an explicit helper function for each individual function that checks the args and either does cb or return new Promise.
 
i'm trying to think
it may be possible to convert a function which returns a promise to one which calls a callback
but you would necessarily have to convert all existing functions to ones which return promise
 
12:36 PM
yes, I found a library that does that. Unfortunately the existing code is not amenable to that sort of transform.
 
in what way?
if you're already having to convert all functions to return promise
it can't get much worse than that I suppose
 
in that it makes extensive use of async.js and large numbers of functions would have to be completely rewritten
 
well the whole point of switching to promises is because callback hell is a pain in the ass to untangle
 
indeed - I'm just trying to make the transition easier
 
If it's your job to convert to promises that's one thing, but otherwise, consider converting to promises just the more heavily used functions
I mean conceivably it's the same thing as the callbacks, so it's hard to justify dedicating a lot of time towards that
 
12:41 PM
The goal is to eliminate the callback hell. It's too big a job to do in one go, so my intended transition is to have the (many) core functions support both methods until eventually when no function is being passed a cb I can then move fully to Promises / async/await.
 
it may be very well easier to find common ground with all your functions and try to combine whenever possible
then you have fewer to convert
 
(the program is Etherpad - it's open source)
 
I don't envy you :P
Doesn't seem that terrible though
 
until you look at doImport and realise that it calls async.series([ ... ], cb) where every function in that array also takes a callback which is ultimately responsible to calling the terminal callback at the end of the sequence
in this particular case the outer function doesn't take a callback, but most of them do
(The library that converts promises to dual promise / nodeback is nodeify - I'm looking for one that converts nodebacks to promse / nodeback)
but if one doesn't exist I guess I'll just have to write it... :p
the other potential complication is that the callstack with promises looks very different than with nodebacks - with the latter execution will immediately resume at the point after the callback was invoked, unless return callback() was used.
 
ugh, I would leave that alone and just focus on the rest
 
12:51 PM
I did make some progress already
var thenify = require('thenify').withCallback;

var somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
  callback(null, a, b, c);
});

// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);
// somethingAsync(a, b, c, function () {});
 
@Alnitak Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
1:50 PM
😲
 
 
1 hour later…
3:04 PM
@Alnitak This exists natively in Node
 
user1596138
3:50 PM
lol
 
@MadaraUchiha that's not the same thing - AFAIK it doesn't leave with you a function that either returns a Promise or invokes a callback, you only get the former.
 
@Alnitak Why would you want both?
Madness lies on that path
 
did you read the whole thread? I'm trying to transition a large project from callbacks to async / promises.
The first step is to make every API call support both, and then gradually I can unravel the callback chains and replace them with promises.
 
I don't think that's how I'd have done it, but I guess that's a legitimate use-case.
I'd just start moving functions (and their entire caller chains) to async.
 
it's a big project
 
4:05 PM
I've been in my big project or two :)
That's still how I'd go about doing so, it's not as difficult as you think it is.
 
and lots of the internals make use of callback-based functions that can't be promisified (because e.g. they use async.waterfall) without being completely rewritten
until you've looked at the code don't presume to tell me how hard it is.
 
@Alnitak async.waterfall is trivially rewritten with for..of and await.
Almost all callback patterns have a 1:1 mapping to async patterns directly.
It's very rare that you'd need to rewrite anything.
But I'll concede the point that I haven't looked at your specific codebase and don't know what sorts of abominations you have to deal with.
 
It's etherpad - the code is public
and not my code - I'm just trying to help them out of their callback hell
 
yes, that.
 
4:08 PM
Some of them accept a cb even though it's not used anywhere.
 
using a transitional mechanism should allow me to run the system tests gradually as I migrate without doing the complete rewrite and only then finding out it's broken.
 
They're... completely misusing async. in some of these, too...
github.com/ether/etherpad-lite/blob/develop/src/node/hooks/… Here for example, the entire code is 100% sync, there's no need for async.series at all
 
yup
 
Well, those low hanging fruits are easy
Do you have an example where you suspect it's going to be more difficult?
 
sec
 
4:11 PM
Wow, this is full of bugs o_O
I can visibly spot bugs in 2 out of 2 random files I've entered
 
I don't see anything here that's overtly difficult to convert, I'll admit
 
none of it is especially hard, but it's all interlinked
 
Yes, but what you're forgetting that you can still keep the outer layer in callbacks while you convert the inner layer.
function fn1(arg, cb) { /* ... */ }

function fn2(arg, cb) {
  // ...
  fn1(something, cb);
}
Becomes
async function fn1(arg) { /* ... */ }

function fn2(arg, cb) {
  // ...
  fn1(something).then(res => cb(null, res));
}
You can then convert fn2 at your leisure
 
sure, except that many of the inner functions are reached through multiple paths
especially when the REST API is involved
 
4:19 PM
Using thenify as your scaffolding pretty much guarantees that 1. you'll miss a few spots 2. in the future, anyone would be able to do whatever they want (callbacks or Promises) and you wouldn't be able to enforce that.
@Alnitak Sure, you need to modify all of the callsites, you can't avoid that.
But I don't see it as a negative thing.
 
the intention is to only use for this transition, and then strip it back out again as each inner function is converted to promises
 
@Alnitak I realize, that's what I meant by scaffolding
 
I was more talking about your second point - the scaffolding would be removed as soon as it's not needed, leaving them only with Promises
 
That's fair
You're going to need to do this in fairly small increments as it is, as I see it, the project is fairly active
I just think that this scaffolding would be more harm than good to you in the long run
 
I've done some already in my own branch
and this is something they'll hold for a major release
 
4:23 PM
Or any keyword by which I can search the better results
 
Oh for sure
 
is how can I make a vpn app using react native, finding no resources by googling, found an app naming react-native-vpn-app which is not running, could anyone please show me some direction so that I can start
 
I mean that if the project is worked on often, you'll need to deal with conflicts pretty much all the time if you try to do it all at once
 
it's not that active
 
Hmm, yeah those two commits from last week are typos/l10n
Fair enough
 
4:25 PM
and I hope to get this done within a week or two - my employer gave me time to contribute to this project
 
4:36 PM
posted on January 21, 2019 by CommitStrip

 
user1596138
5:15 PM
Anyone planning to attend a North American front-end conf this year?
 
user1596138
Can't find anything interesting atm
 
user1596138
Everything's old news this year lol
 
user1596138
@Alnitak That's sweet.
 
@Jhawins I do work for an open source company anyway, with our own products, but we depend on etherpad a lot, so we want to contribute back
 
2
Q: Removing Linebreak in Script

hannahThis is probably an incredibly simple answer, but I don't have a clue what I'm doing and can't find answers that work. Trying to get this to say "Currently Booking Next-Month" on one line, but there is a linebreak between "currently booking" and the month. <html> <body> <h2>Currently Booking<h2...

 
 
2 hours later…
7:41 PM
@Jhawins I'm going to the next jsi in vancouver probably but that's like... october
TBH it's a long flight to goo to your side of the globe :D
 
8:40 PM
0
Q: How do I reference a line of code in JavaScript?

Wally GlascoffI’m trying to teach myself JavaScript. I want to be able to reference a line of code so the system can identify it and register it. console.log(a * w_discount - a * tax - a) How do I link the answer of this up to do further coding with it?

How difficult would it be to.. "learn" javascript given no reference material of any kind, like, just throwing characters and what not at it and learning from the errors
 
user1596138
@BenjaminGruenbaum Haha yeah I wasn't expecting you to be out here.
 
user1596138
Vancouver is STUPID far from me too
 
user1596138
Like 30 hours lol
 
user1596138
There's so many cool looking things overseas..
 
i wouldn't attend one even if it was right across the street
 
user1596138
8:50 PM
Wow, buzzkill
 
Is someone pretty savy with working with HTML/js canvas?
 
user1596138
Someone is
 
user1596138
I think
 
user1596138
@KevinB No elaboration? I miss networking
 
9:07 PM
Well if someone wants to look into how to get the white part of my screened waves a solid color have at it cause i been stuck on getting it to work for hours: jsfiddle.net/rtarson/vbku8sjx/4/#&togetherjs=gnajrLpoSA
 
Just doesn't seem interesting
i can get the same content from youtube
and easily close it when i find the content boring
plus it's free
 
user1596138
The content is far from the main attraction IMHO
 
right
 
user1596138
Unless there is new content anyway..
 
like, the conferences I went to back in college, i enjoyed the trip and spending time with friends. the conference was secondary
 
user1596138
9:12 PM
I share your opinion from a slightly different angle.
 
woulda been more enjoyable to skip the conference part
(if not for the fact that the college was paying for it and the trip and everything we did)
 
user1596138
Idk. Seeing what the current buzz is by actually observing and conversing with 300 people at a conference is cool to me
 
user1596138
My work would pay for it. So I wouldn't just have a vacation with friends by any means
 
user1596138
But yeah, "getting started in React" is going to be workshop at any current conf. Which is mundane at best
 
user1596138
Crockford went ape shit about Seif Project last one I went to, then got SJWed out of the industry haha
 
user1596138
9:14 PM
That was funny.
 
user1596138
In a sad kind of way... Entertainment nonetheless
 
9:30 PM
is there a Imgur that doesn't compress image and doesnt have limits on file sizes and video lengths?
 
 
1 hour later…
user1596138
11:00 PM
The last message was posted 1 hour ago.
 
11:36 PM
literary 80+% of my codelines for the server end are lines to "catch and handle bad input"... Really feels like a waste and it clutters from the main goal of a function :/
 
well, you might want to look into a validation library
 
don't allow users to submit stuff
 
user1596138
Idk he didn't define it well
 
user1596138
"Bad input" could be entering duplicates that only the backend knows about
 
user1596138
Not enough to say "Stop it on the client"
 
11:40 PM
kevin was joking
 
user1596138
But yeah, if you're actually validating the semantics of data etc on the backend... That's just stupid
 
something along the lines of "for max security, unplug your computer"
 
user1596138
Nah, he was saying do client side validation and stop the submission. I assume.
 
Well a function is like (say get-employee-hours_worked): > check login info -> on insufficient rights return info about rights, -> check input parameters -> give a message per missing parameter -> check domain of parameters -> outside allowed domain/duplicates/etc give errors specific to what is broken -> get database data -> check if database is alive -> check if returned values are not gibberish -> build response.
 
nah, i was being sarcastic
 
11:43 PM
only the "get database data" and "build response" consist of actual thought process to create. The rest is all silly code.
@Jhawins you always have to do this. As you don't know if the client actually uses your frontend (nor should you care).
This creates lots of duplicate code though, as you also like to validate data on front end to be more responsive. - yet you're obviously required to do so on the backend.
 
the front-end validation is to improve the user interface more so than validating data
on the backend, it's easy to just return a response of "invalid request" if the input is invalid, but that'd be a terrible user experience if you just told them they did something wrong
but if you have front-end validation that handles that, then the backend doesn't need to be nearly as verbose
 
Indeed, but since it's "trivial" to create (it's so easy to write data validation lines, hell to me it's easier than writing a line in english to chat here) it's something I tend to do always. However as I always do it, it slowly increase overal complexity.
it = data validation
 
it can, as stated, simply return invalid request and be done with it. the validation logic can be centralized such that it can be re-used across all your endpoints (aka by using a library)
in coldfusion for example i simply setup queryparams that ensure the data is of a particular type within min/max limits, and any failure due to that can be easily responded to with a 400, which is handled globally rather than per route
if it's supporting a user facing form, i make it user friendly with front-end validation
the bots won't care why it was rejected
 

« first day (3019 days earlier)      last day (1934 days later) »