Hello, in this video, we are going to take a look at validating an integer within a range. So simply put, if we have an integer, let's say five, and the maximum can be 10. And the minimum is one, five would be true would be within the range. Whereas if I didn't have five to 512, maybe some user input, then it will be false. So where could you use this, maybe you get some user input. And again, you have, you know, the range.
So you might have the range for let's say, age, potentially, even though, you know, some may argue that you could go, you know, be older, you know, then 120 130 there's, you know, some sort of limit, you know, applied to it. So let's say if we put a limit to 200, nobody lived up to 200 years old, that you know, anybody knows of, and the minimum age I guess, would be zero. So you don't want to you know, above or below those ranges personally is really simple on the crease and number and obviously the you know the one to 10 example, then I could for you from this to this and now we need to set the min boundaries, so this is going to be equal to one and then we'll have the max boundaries which is equal to 10. Okay, so now to actually do the check, all we do is we do an if statement and if filter on the scoreboard.
Then we provide the number that would check in then we need to say filter on school validate into just so you know, what type of data are we validating. Next, we need to give it an array and the array we have to define the options This option itself, sections in here has an array. And this is the first item I mean on the score range, the main variable, and we'll put a comma, and then we'll put Mac on the score range. Just you just assign it the okay. Okay, so put the wrong character for the key brand new pair, dollar max. And let me see what we got here, where we would do check so we could, you know, check if it's true, but you know, the assemble automatically checklists.
Okay, so we're gonna say echo within range. And then we'll do an L same not in range, not in and what you can do as an extra task is to make it a bit more contextual. So you're saying, you know, let's say your number five is within the range of one and 10 and for the fuel say your number I think 12 is not within the range of one so far reload this we get undefined variable, okay? Nothing okay. within range, so let's pull up 60 bigger, okay, that you know, good. Why what if you don't mind?
Metro in a Muslim low work it still good as far as the rustle getting close Do it so fine, whatever you want. That's fine because you know, he's inclusive, and then just confirm it with the upper boundary. There we go. I'll change it back to five. So that's it. That is how you validate an integer within a range.
Nothing more to it than that. If you have any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.