Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":27695,"date":"2015-11-25T09:43:59","date_gmt":"2015-11-25T15:43:59","guid":{"rendered":"http:\/\/charliegdrummer.wordpress.com\/?p=240"},"modified":"2015-11-25T09:43:59","modified_gmt":"2015-11-25T15:43:59","slug":"masteries-299-validate-what-the-user-inputs","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2015\/2015\/masteries-299-validate-what-the-user-inputs\/","title":{"rendered":"Masteries 29,9: Validate what the user inputs"},"content":{"rendered":"

Here I will show show an easy way to validate what the user inputs specially what type of data is typing.<\/p>\n

That means that you can restrict the user to type something no longer than 10 characters, or to type only an integer or a float. Here I going to show you those three cases (something no longer than ten characters, an integer, and a float).<\/p>\n

 <\/p>\n

So let’s start with the easiest one; to restrict the number of character the user can type, it is easy to use the length command.<\/p>\n

len(variable)<\/p>\n

it will return the number of characters in case of a string, the number of elements it has in case of a list.<\/p>\n

REMEMBER, in order to do this, the variablke must be either a string or a list, otherwise it won’t work<\/p>\n

With a loop with the condition of what the user is typing is longer than ten characters, you can r4estrict the interaction of the user and don’t let him go until he types what you want<\/p>\n

So for the program we will ask a nickname no longer than ten characters, the loop after asking the nickname will be:<\/p>\n

\"string\"<\/p>\n

So it will loop untill the user types it correctly<\/p>\n

 <\/p>\n

Then, we will review a little harder one; to restrict the user to only type an integer; that means the input won’t have a “.” inside of it, and it can be converted to integer via python.<\/p>\n

There exists a common way to validate that which is by exceptions in a loop. With a loop that it’s only condition is to be true, you will use the command try, to, well, try to do something, in this case, to convert the input of the user to integer via python, variable = int(variable); if it results like an error, represented in python as ValueError, then it will ask again for the number. This loop is to make sure the user didn’t input letters, just numbers.<\/p>\n

After doing that, is necessary to verify if the input has a decimal point”.”, in that case, it will ask again for the number<\/p>\n

So it will look like this<\/p>\n

\"integer\"<\/p>\n

 <\/p>\n

The last one, the float, its a little more ease, it just have to work if you try to convert it to float; you will use the same structure, but you will try to convert it to float instead to int variable = float(variable)<\/p>\n

It will result like this:<\/p>\n

\"float\"<\/p>\n

Here you saw not just how to validate, but learned the basic types of data<\/p>\n

The strings, that are just characters<\/p>\n

The integers, that are just numbers, not fractions, not decimals<\/p>\n

The floats, that are numbers with decimal points<\/p>\n

 <\/p>\n

It is easy isn’t it?<\/p>\n

\"Eazy-E.jpg\"<\/p>\n

\"\"<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"

Here I will show show an easy way to validate what the user inputs specially what type of data is typing. That means that you can restrict the user to type something no longer than 10 characters, or to type only an integer or a … Continúa leyendo Masteries 29,9: Validate what the user inputs<\/span><\/a>\"\"<\/p>\n","protected":false},"author":191,"featured_media":27691,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[227,45,372,39],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27695"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/users\/191"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/comments?post=27695"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27695\/revisions"}],"predecessor-version":[{"id":28082,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27695\/revisions\/28082"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media\/27691"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media?parent=27695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/categories?post=27695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/tags?post=27695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}