Tag Archives: validation

PHP regex for url validation, filter_var is too permisive

Questions: First lets define a “URL” according to my requirements. The only protocols optionally allowed are http:// and https:// then a mandatory domain name like stackoverflow.com then optionally the rest of url components (path, query, hash, …) For reference a list of valid and invalid url’s according to my requirements VALID stackoverflow.com stackoverflow.com/questions/ask https://stackoverflow.com/questions/ask http://www.amazon.com/Computers-Internet-Books/b/ref=bhp_bb0309A_comint2?ie=UTF8&node=5&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=browse&pf_rd_r=0AH7GM29WF81Q72VPFDH&pf_rd_t=101&pf_rd_p=1273387142&pf_rd_i=283155… Read More »

Zend form validation

Questions: I am using Zend Form to create dynamic form. I have Zend Form validation too. Trying to remove Validation dynamically, but not getting any success. Can you plz help me to remove Zend Validation. Bellow is my code for remove validation : $toRemValArray = array(); $toRemValArray[0] = ‘ele_4af42ceac7810’; if(isset($_POST[‘btnPost_x’])){ if ($form->isValid($_POST)) { $allElements =… Read More »

How does OpenID user validation works?

Questions: Well im trying to implement Steam OpenID login to a website but im not quite sure how it’s done and how does Steam validate users who are loged in with OpenID. As for now what i have found out is that steam only gives user id back and nothing else so for the rest… Read More »

File upload mime-type validation with Laravel 4

Questions: When I upload a well-formed MP3 file, Laravel 4 tells me it’s not audio/mp3 but application/octet-stream, which makes this validation fails: $validator = Validator::make( array(‘trackfile’ => Input::file(‘trackfile’)), array(‘trackfile’ => ‘required|mimes:mp3’) ); if($validator->fails()) return ‘doesn\’t works because mime type is ‘.Input::file(‘trackfile’)->getMimeType(); else return ‘it works!’; Why doesn’t it upload the file as an audio/mp3 file… Read More »

Laravel validation: Required only and only one field

Questions: I have got two fields namely number and percentage. I want a user to input value in only one input field. If a user inputs values in both number and percentage field, the system should throw validation error. Is there anything we can do with laravel validation to achieve this? Thanks. Answers:

Form validation rules for regex_match

Questions: I’m trying to figure out what I’m doing wrong with this validation rule because its saying this error. Validation rule: $this->form_validation->set_rules(‘username’, ‘Username’, ‘trim|required|xss_clean|regex_match[a-z0-9]’); Error: Severity: Warning Message: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash Answers:

is_unique for codeigniter form validation

Questions: I’m trying to figure out how I can use the is_unique rule from the Codeigniter form validation library in the following situation. I’m trying to submit a edit user form and have the rule: $this->form_validation->set_rules(‘user_name’, ‘User Name’, ‘required|trim|xss_clean|is_unique[users.user_name]’); What if other values in the form are being changed but this value stays the same.… Read More »