All language subtitles for 005 Applying Rules_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,210 --> 00:00:04,650 In this lecture, we're going to apply the rules we defined to our forms. 2 00:00:04,650 --> 00:00:06,660 Let's use it for our input. 3 00:00:06,660 --> 00:00:12,630 Back in the authentication component, we can enforce a rule on the input by binding an attribute on 4 00:00:12,630 --> 00:00:15,000 the field component called rules. 5 00:00:17,280 --> 00:00:22,380 The value for this must be a list of rules you'd like for the value to be checked against. 6 00:00:22,410 --> 00:00:25,230 We're going to set this property to required. 7 00:00:27,560 --> 00:00:30,350 This is one way of adding a rule to an input. 8 00:00:30,380 --> 00:00:32,720 There's a second way, which is much better. 9 00:00:32,750 --> 00:00:35,840 The template and our component is starting to get cluttered. 10 00:00:35,870 --> 00:00:38,740 We're adding a lot of code to achieve validation. 11 00:00:38,750 --> 00:00:43,130 We can make our template look cleaner by outsourcing the rules to an object. 12 00:00:43,490 --> 00:00:49,850 This is the route we'll be going with will remove the rules attribute from the field component. 13 00:00:52,290 --> 00:00:57,150 On the the form component will bind a property called validation schema. 14 00:00:59,420 --> 00:01:04,550 The validation scheme of property allows us to outsource the rules into an object. 15 00:01:04,580 --> 00:01:08,910 The value for this property must be an object from our components data. 16 00:01:08,930 --> 00:01:11,210 We'll set this property to schema. 17 00:01:13,630 --> 00:01:15,890 This object currently doesn't exist. 18 00:01:15,910 --> 00:01:20,170 Let's add it to our component in the component configuration options. 19 00:01:20,170 --> 00:01:22,030 We'll add the data function. 20 00:01:24,210 --> 00:01:27,630 In the object, we'll define the schema object. 21 00:01:29,890 --> 00:01:35,210 The property name in the object must reference the unique identifier we gave to the input. 22 00:01:35,230 --> 00:01:40,330 This would be the value we used in the name attribute on the field component. 23 00:01:40,360 --> 00:01:43,060 We want to add rules for the name field. 24 00:01:45,430 --> 00:01:51,430 The value for this must be a string with the rules we want to enforce, we'll set this to required. 25 00:01:53,690 --> 00:01:56,270 While we're here, we'll add the other fields. 26 00:01:56,270 --> 00:02:01,580 Since we'll be validating them in upcoming lectures, we'll add the following properties. 27 00:02:01,760 --> 00:02:02,600 Name. 28 00:02:05,040 --> 00:02:05,820 Email. 29 00:02:08,150 --> 00:02:08,960 Age. 30 00:02:11,200 --> 00:02:12,160 Password. 31 00:02:14,310 --> 00:02:15,660 Confirm password. 32 00:02:17,830 --> 00:02:18,760 Country. 33 00:02:20,970 --> 00:02:22,020 Cos. 34 00:02:24,350 --> 00:02:27,790 We aren't going to add rules for all the input at once. 35 00:02:27,800 --> 00:02:31,010 We're just adding these in to save some time in the future. 36 00:02:31,200 --> 00:02:33,650 We've completed the first three steps. 37 00:02:33,650 --> 00:02:35,960 The last step is to handle the error. 38 00:02:36,140 --> 00:02:40,800 If the input is invalidated, we'll want to provide feedback to the user. 39 00:02:40,820 --> 00:02:42,960 There are different ways to handle this. 40 00:02:42,980 --> 00:02:47,580 We're going to output a message below the input for displaying the error. 41 00:02:47,600 --> 00:02:50,680 There's a component for outputting error messages. 42 00:02:50,690 --> 00:02:52,780 It comes with validate. 43 00:02:52,790 --> 00:02:55,650 It's the easiest way for outputting errors. 44 00:02:55,670 --> 00:02:58,310 First, we need to register the component. 45 00:02:58,310 --> 00:03:00,850 Switch over to the validation file. 46 00:03:00,860 --> 00:03:07,190 At the top, we're going to update the import list from the validate package to include a component 47 00:03:07,190 --> 00:03:08,750 called error message. 48 00:03:10,880 --> 00:03:17,660 Next scroll down to the install method, we're going to register the component with the app component 49 00:03:17,660 --> 00:03:18,410 function. 50 00:03:18,410 --> 00:03:22,190 The name of the component will be the same name as the object. 51 00:03:24,500 --> 00:03:28,220 The component we have registered will output an error message. 52 00:03:28,220 --> 00:03:31,880 If there isn't an error message, nothing will get outputted. 53 00:03:31,880 --> 00:03:35,720 That saves us time from having to check if there's an error message. 54 00:03:35,720 --> 00:03:37,640 It's a very simple component. 55 00:03:37,640 --> 00:03:40,490 Let's use it back in the component. 56 00:03:40,490 --> 00:03:46,130 We're going to add the error message component below the field component for the name. 57 00:03:48,600 --> 00:03:52,770 We're going to add a class called Text Red 600. 58 00:03:55,000 --> 00:03:59,650 The error message component will generate a span tag if there's an error. 59 00:03:59,680 --> 00:04:02,290 Any attributes we add to the component? 60 00:04:02,290 --> 00:04:05,170 Will you passed onto the element it generates? 61 00:04:05,170 --> 00:04:09,280 The class we're adding will change the color of the text to read. 62 00:04:09,550 --> 00:04:13,540 The next thing we'll do is tell the validate which error to output. 63 00:04:13,570 --> 00:04:15,970 We'll add a property called name. 64 00:04:15,970 --> 00:04:18,370 Its value should be the name of the field. 65 00:04:18,370 --> 00:04:24,880 It should output errors for the value should correspond to the value we passed into the name property 66 00:04:24,880 --> 00:04:26,440 for the field component. 67 00:04:26,470 --> 00:04:32,620 In this example, we're trying to output the error message for the name we'll pass in name. 68 00:04:35,340 --> 00:04:37,980 Each field will have only one error. 69 00:04:38,100 --> 00:04:44,850 There can be multiple errors for an input, but the error message component will only output one error. 70 00:04:45,060 --> 00:04:46,510 That's perfectly fine. 71 00:04:46,530 --> 00:04:50,370 We don't need to view every error on an individual input. 72 00:04:50,760 --> 00:04:51,780 We're finished. 73 00:04:51,810 --> 00:04:56,620 There are more things we can do, but I think it's time we test the form in the browser. 74 00:04:56,640 --> 00:04:58,350 Open the registration form. 75 00:05:00,830 --> 00:05:02,340 Everything will look normal. 76 00:05:02,360 --> 00:05:06,300 Validation is not performed until the fields have been touched. 77 00:05:06,320 --> 00:05:11,390 If we were to input random text into the name field, we wouldn't receive an error. 78 00:05:11,720 --> 00:05:15,170 Let's see what happens if we were to leave the field empty. 79 00:05:17,450 --> 00:05:19,310 An error will appear below. 80 00:05:19,340 --> 00:05:22,990 By default, the validate generate an error message. 81 00:05:23,000 --> 00:05:25,880 The rules we've imported are functions. 82 00:05:25,880 --> 00:05:28,930 The functions will return either true or false. 83 00:05:28,940 --> 00:05:32,770 We can override this, but we'll get to that in the next few lectures. 84 00:05:32,780 --> 00:05:35,450 For now, the default message will work. 7603

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