All language subtitles for 017 Triggering Validation_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,830 --> 00:00:05,750 In the last section, we spoke about how calling the validate function on the foreign state object finds 2 00:00:05,750 --> 00:00:10,970 all the different text form fields and invokes the validator property that has been assigned to each 3 00:00:10,970 --> 00:00:12,200 one of those text form fields. 4 00:00:12,650 --> 00:00:18,560 So in this section, we're going to define our validator function on both our email field and the password 5 00:00:18,560 --> 00:00:19,490 field as well. 6 00:00:20,570 --> 00:00:25,850 So when the validator function is called, it receives as the first argument, the current value of 7 00:00:25,850 --> 00:00:31,130 the text form field, so we can receive that as an argument to this function as simply something like, 8 00:00:31,130 --> 00:00:31,910 I don't know, value. 9 00:00:32,600 --> 00:00:37,610 And then since this is a text form field, that argument that comes in here is always going to be a 10 00:00:37,610 --> 00:00:38,060 string. 11 00:00:38,060 --> 00:00:40,070 And so optionally we can market as a string. 12 00:00:40,340 --> 00:00:43,910 Otherwise, if you hover over it, it's going to say, yeah, this is you're going to receive a string 13 00:00:43,910 --> 00:00:44,150 here. 14 00:00:45,290 --> 00:00:47,720 And what the heck, I'll just market as a string for fun. 15 00:00:49,030 --> 00:00:54,460 It's now inside the validator function, we need to look at the value of this thing and if it's valid, 16 00:00:54,460 --> 00:00:59,410 valid, and if it looks essentially like an email address that we're happy with, we're going to return 17 00:00:59,410 --> 00:01:01,000 nothing or return null. 18 00:01:01,540 --> 00:01:06,730 Otherwise, we're going to return a string that represents the error message or something to tell the 19 00:01:06,730 --> 00:01:09,790 user what is wrong with the value that they just entered. 20 00:01:10,690 --> 00:01:15,040 So for you and me, just to keep life really straightforward, really simple. 21 00:01:16,140 --> 00:01:21,350 You and I are going to say that an email address is valid if it contains an at symbol. 22 00:01:21,900 --> 00:01:29,430 So if someone enters something like that for the sake of this application, this is a valid email for 23 00:01:29,430 --> 00:01:29,720 us. 24 00:01:29,780 --> 00:01:32,160 OK, we're just going to check to see if there's an at symbol in there. 25 00:01:32,280 --> 00:01:35,770 If it has it great, that's a valid email and we're happy with it. 26 00:01:36,510 --> 00:01:38,940 So inside of here, we're going to see if. 27 00:01:39,970 --> 00:01:47,860 Value contains at and specifically, we want to find the case in which the string does not contain and 28 00:01:47,860 --> 00:01:51,970 assemble, so I'm going to put a exclamation right before it to flip the value. 29 00:01:52,420 --> 00:01:53,980 So now we're saying if. 30 00:01:55,470 --> 00:01:56,550 The current value. 31 00:01:58,100 --> 00:02:05,090 Does not contain an act then we consider this thing to be invalid and we need to return a string that 32 00:02:05,090 --> 00:02:06,740 will tell the user what's wrong here. 33 00:02:08,009 --> 00:02:13,770 So if that's the case, I'm going to return a string that says, please enter a valid email. 34 00:02:15,130 --> 00:02:15,640 Like so. 35 00:02:17,450 --> 00:02:22,580 Now, technically, we do not need to actually put in a return null case if we don't return anything 36 00:02:22,580 --> 00:02:27,820 inside of here than by default, null is returned so we can really just leave this as is. 37 00:02:27,830 --> 00:02:32,330 Or if you want to be really explicit, you can add on a return call at the bottom. 38 00:02:32,360 --> 00:02:34,130 It's totally up to you, but I'm going to leave it off. 39 00:02:35,420 --> 00:02:39,650 OK, so that's our validator for the email address, I am going to clean up the comment here. 40 00:02:41,380 --> 00:02:46,300 And now we're going to go down to our password as well and add in a validator for that text form, feel 41 00:02:46,300 --> 00:02:54,730 to so on my password fields to find my text form fields, I'm going to pass in a validator that's going 42 00:02:54,730 --> 00:02:55,420 to be called. 43 00:02:56,740 --> 00:03:01,210 With current value of the field and we need to look at this value and decide whether or not the user 44 00:03:01,210 --> 00:03:06,330 has entered a valid password, and so, again, we're going to set up a arbitrary requirement here. 45 00:03:06,580 --> 00:03:12,190 We're going to say that a password is valid if it has at least four characters. 46 00:03:12,710 --> 00:03:13,990 So we're going to say if. 47 00:03:15,320 --> 00:03:23,240 Password length is less than four or seven, not password value length, so if there are less than four 48 00:03:23,240 --> 00:03:26,330 characters in there, then we're going to assume this is not a valid password. 49 00:03:26,750 --> 00:03:32,960 And we'll return a string that says password must be at least four characters. 50 00:03:34,830 --> 00:03:35,340 Like so. 51 00:03:37,220 --> 00:03:37,970 Oops, forgot. 52 00:03:38,010 --> 00:03:39,320 Come on, let's fix that. 53 00:03:39,380 --> 00:03:39,830 There we go. 54 00:03:41,500 --> 00:03:46,240 OK, so we've now defined our validator functions on both of our text form fields. 55 00:03:48,250 --> 00:03:54,520 Which means we can now go back to our form state objects and call the validate method on it. 56 00:03:56,160 --> 00:03:57,450 Sit down inside of my. 57 00:03:58,420 --> 00:04:04,210 Submit button on press handler whenever a user presses this thing, rather than attempting to reset 58 00:04:04,210 --> 00:04:05,000 the entire form. 59 00:04:05,020 --> 00:04:10,180 I'm going to instead call validate and then to figure out whether or not this thing is actually working. 60 00:04:10,190 --> 00:04:12,410 I'm going to put that inside of a print statement. 61 00:04:12,970 --> 00:04:18,399 So if our form is valid now, we should see true printed out at the terminal otherwise that the form 62 00:04:18,399 --> 00:04:19,110 is not valid. 63 00:04:19,120 --> 00:04:21,160 We should see false printed out instead. 64 00:04:22,180 --> 00:04:23,350 All right, so I'm going to save this. 65 00:04:25,180 --> 00:04:28,840 We're going to do our refresh and we'll test this out in the emulator. 66 00:04:34,190 --> 00:04:35,630 All right, so moment of truth. 67 00:04:36,080 --> 00:04:42,440 So first off, as everything stands right now, form is not valid because our email does not have a 68 00:04:42,710 --> 00:04:45,920 character in it and our password field does not have four characters. 69 00:04:46,310 --> 00:04:51,320 So if I click on Submit, I should see something that indicates, hey, form is not valid and it cannot 70 00:04:51,320 --> 00:04:51,870 be submitted. 71 00:04:52,280 --> 00:04:58,640 So if I click on submit, I see in my terminal false printed, which means the form is not valid. 72 00:04:58,760 --> 00:05:04,040 And I also see those two strings that we added inside of those validators appear on here as well to 73 00:05:04,040 --> 00:05:07,520 indicate to our user, hey, something's wrong with the form and you need to fix it up. 74 00:05:08,270 --> 00:05:14,150 So now if I enter in what we consider to be a valid email, which is anything that contains the symbol. 75 00:05:15,300 --> 00:05:22,830 And then a password of four characters or more and then click submit again, our form is now valid and 76 00:05:22,830 --> 00:05:26,450 we see true reflected down here to say, yep, form valid and you're good to go. 77 00:05:27,000 --> 00:05:32,940 And then, of course, if I revert back to an invalid state where I've got to say one letter password. 78 00:05:33,830 --> 00:05:37,280 It tells me, hey, not valid anymore, any of these four characters. 79 00:05:37,790 --> 00:05:40,340 OK, so that's it, that's form validation. 80 00:05:40,700 --> 00:05:42,410 Again, key thing to remember here. 81 00:05:43,860 --> 00:05:46,510 When we want to access our form, we have to create that global key. 82 00:05:46,890 --> 00:05:50,820 It's going to be tied to our form state object and then on the form state object. 83 00:05:51,000 --> 00:05:56,340 We've got this validate function when we call validate, it's going to automatically find all the text 84 00:05:56,340 --> 00:06:01,530 form fields that are nested inside of our form and attempt to call the validator function associated 85 00:06:01,530 --> 00:06:02,250 with each one. 86 00:06:03,440 --> 00:06:05,400 All right, so we're not quite done yet. 87 00:06:06,440 --> 00:06:12,000 We have successfully validated those inputs, but we have not yet had the ability to somehow, like, 88 00:06:12,080 --> 00:06:14,150 get the actual value out of them. 89 00:06:14,600 --> 00:06:20,290 Yes, we are passing the value to the validator function, but that doesn't quite seem right. 90 00:06:20,330 --> 00:06:23,900 So now that we have the ability to validate this thing, I now want to make sure that we also have the 91 00:06:23,900 --> 00:06:29,530 ability to retrieve the values that the user entered and, I don't know, do something with them, you 92 00:06:29,540 --> 00:06:32,750 know, say, hey, you're not assigned and or whatever else. 93 00:06:33,230 --> 00:06:36,590 So let's take a quick break and we'll finish up with that in the next section. 9435

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.