PHP Validation Basics


Published on

Learn how to use the native validation methods in ProdigyView. Includes validating mime types of files.

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

PHP Validation Basics

  1. 1. PHP Validation Basics
  2. 2. OverviewObjectiveLearn the native features of validation in ProdigyView.Requirements Understanding of mime types Basic knowledge of the file managerEstimated Time8 Minutes
  3. 3. Follow Along With Code Example1. Download a copy of the example code at Install the system in an environment you feel comfortable testing in.3. Proceed to examples/util/Validation.php
  4. 4. ValidationValidation is process of the checking data against a set ofparameters. If the parameters match, a true is returned,otherwise false.Validation can be used internally but it most commonlyused with checking user input.In this tutorial, we will be briefly introducing you tocommon validation used in PHP and its nativeimplementation in ProdigyView.
  5. 5. Integer ValidationInteger validation is a good point to start. An exampleusage is many SQL databases use auto incremented idswhich are integers. You may want to verify that the id theyare going to use to update a record is an integer.
  6. 6. Double ValidationDouble validation will cover validation for types double,floats, longs, and anything else that contains a periodand a number. Passing an integer to double validationwill fail.
  7. 7. Email ValidationA common validation with web applications is the email.You want the user who is registering for the application toat least enter a real email.
  8. 8. Audio File TypeOn your way to making the next Pandora? In that caseyou want audio file mime type validation. While theexample below checks all audio mime types, it can befurther specified to check only one type. Supported validation formats: mp3, wav, ra, oga, midi, aif
  9. 9. Video File Types Similar to the audio file type, video mime types can also be validated. The example below is also all inclusive but video mime types can be checked individually.Supported Validation Formats:ogv, mpeg, wmv, mp4, flv, quicktime, mov, mxu , avi, realvideo, asf, webm
  10. 10. Image File TypesCheck image file types before deciding to accept them.Below is the method checking all images types but theycan also be checked individually.Supported Validation Formats: png, gif, jpeg, ief, bmp,tiff
  11. 11. Compress FilesCompressed files include zip, tar and gtar. Validate thatthe file is actually a compressed file and does not merelyhave the extension of a compressed file.
  12. 12. Microsoft FilesMicrosoft files include Word, Excel and Powerpoint. Dividedfurther, we have .doc, docx and so forth, each which hasdifferent mime-types. In ProdigyView, we can validateagainst any of those Microsoft file types.
  13. 13. Other ValidationThis tutorial only showed a brief overview native validationin ProdigyView. There are many more validation typeavailable, read through the api.There is also the ability to add custom validation toPVValidator in the tutorial on ‘Custom Validation’. Other Native Validation Examples isValidUrl  IsCSSFile isActiveUrl isPdf isID
  14. 14. Challenge!This is optional challenge that will help you betterunderstand Validation and File Management.1. Located a video file on your computer/server.2. With PVFileManager, retrieve the mime type of the video file3. Check against the file type specifically. Example, if the video file is an avi, validate ONLY against avi files.4. If the validation passed, copy the file to another location using PVFileManager.
  15. 15. API ReferenceFor a better understanding of Validation in ProdigyView, visitthe api by clicking on the link below.PVValidator More Tutorials For more tutorials, please visit: