Questions tagged [zend-validate]

Zend Framework provide the validate class to validate the forms elements. Zend have this class in library. This tag is for validation in zend framework.

The Zend_Validate component provides a set of commonly needed validators. It also provides a simple validator chaining mechanism by which multiple validators may be applied to a single datum in a user-defined order.

Zend_Validate supplies a set of commonly needed validators, but inevitably, developers will wish to write custom validators for their particular needs. The task of writing a custom validator is described in this section.

Zend_Validate_Interface defines two methods, isValid() and getMessages(), that may be implemented by user classes in order to create custom validation objects. An object that implements Zend_Validate_Interface interface may be added to a validator chain with Zend_Validate::addValidator(). Such objects may also be used with Zend_Filter_Input.

As you may already have inferred from the above description of Zend_Validate_Interface, validation classes provided with Zend Framework return a boolean value for whether or not a value validates successfully. They also provide information about why a value failed validation. The availability of the reasons for validation failures may be valuable to an application for various purposes, such as providing statistics for usability analysis.

Basic validation failure message functionality is implemented in Zend_Validate_Abstract. To include this functionality when creating a validation class, simply extend Zend_Validate_Abstract. In the extending class you would implement the isValid() method logic and define the message variables and message templates that correspond to the types of validation failures that can occur. If a value fails your validation tests, then isValid() should return FALSE. If the value passes your validation tests, then isValid() should return TRUE.

223 questions
1
vote
1 answer

Add a Validator 2 times in an Element on Zend

I made a Validator that receives a class instance and a function name and then executes it. This is usefull for execute many custom validations through database table mappers. The problem is that I can't add this validator more than one time to a…
1
vote
2 answers

Zend - Can you use a validator to check a username password combination in a Zend_Form?

I have examined Zend Framework: Zend_Validate_Db_RecordExists and Zend_Validate_Db_NoRecordExists, and observed that you can check columns in a database table to see if the value in your form appears in a named column. I have also observed that you…
8bitjunkie
  • 12,793
  • 9
  • 57
  • 70
1
vote
2 answers

How do I hash an element in a registration form in Zend?

I tried looking around and I couldn't find anything. I want to hash the password on the registration page before it inserts into the database. I did some searching, and I found some hash related things for addValidator(), but from my understanding,…
Strawberry
  • 66,024
  • 56
  • 149
  • 197
1
vote
1 answer

Zend_From Validator only if the field input has changed?

I'm writing a Backend System and I want to allow the users to change their email address. I've written a custom validator to check if the email-address the user has entered already exists in my database. Now I ran into a problem: The form is…
Matthias
  • 193
  • 1
  • 9
1
vote
3 answers

Validating date format with Zend_validator

How can I validate the date format (dd-mm-yyyy) using zend_validate?
rukabillaan
  • 241
  • 4
  • 13
1
vote
1 answer

Zend Form MutliCheckbox Validate Number of Checked Items

I have a Zend Form with a MutliCheckbox element. I would like to validate the number of checked items, i.e. verify that exactly 3 items are checked. Can I do it with any current validates or do I have to write my own? Thanks.
Ran
  • 4,117
  • 4
  • 44
  • 70
1
vote
2 answers

Zend_Validate good strategy to avoid repetition of code

I'm am currently building two custom validators that extends Zend_Validate_Abstract which are named respectively Lib_Validate_TimeAfter and Lib_Validate_TimeBetween. The names a pretty straight forward, the first one is used to test if a…
JF Dion
  • 4,014
  • 2
  • 24
  • 34
1
vote
2 answers

Having issues with Zend Validation (Zend_Validate_Db_NoRecordExists)

I'm setting up a user registration page, and am validating on the username field which checks firstly if the user doesn't already exist, secondly if the username isn't a reserved one. My problem is when I attach the two validators to the form…
Paul
  • 756
  • 1
  • 10
  • 22
1
vote
2 answers

Zend Honeypot Validation

On my bootstrap I don't have a class, it's a simple php file: I have added there: $loader = Zend_Loader_Autoloader::getInstance (); $loader->setFallbackAutoloader ( true ); $loader->suppressNotFoundWarnings ( false ); //resource…
MEM
  • 30,529
  • 42
  • 121
  • 191
1
vote
4 answers

regular expression for phone number in php

I am using zend form validation for a phone number. and I want, user should enter phone number in these formats: "+91-151-1234567", "01234567891", "+912345678901" so i am using this regular expression: "^(?:\+?([0-9]{3})\)?[-.…
Chirayu
  • 4,693
  • 7
  • 28
  • 46
1
vote
1 answer

How to add regex validator in form class in zend

I have a User form class which has elements and I am trying to add Regex validator. Here is what I have tried $inputFilter->add([ "name" => "password", "required" => true, "filters"…
Ali Rasheed
  • 2,765
  • 2
  • 18
  • 31
1
vote
4 answers

zend validator regex

I'm trying to use a regex validator on a zend form element like this- $textarea = $this->createElement('text','scores'); $textarea->setLabel('Enter a comma separated list of numbers'); $textarea->setDecorators( …
PeterL
  • 175
  • 5
  • 15
1
vote
1 answer

Need help with Zend form textbox validation

Currently Im developing a website with Zend framework. I need help with my suburb name validation I need the validation to check if the input is in the following format Suburb Name comma symbol space State abbreviations (State abbreviations consist…
user648198
  • 2,004
  • 4
  • 19
  • 26
1
vote
1 answer

zend framework 2/3 multicheckbox disable isEmpty errorMessage

By default a multicheckbox element triggers an error message when none of the options are selected: array (size=1) 'checkbox' => array (size=1) 'isEmpty' => string 'Value is required and can't be empty' (length=36) I found out that…
1
vote
3 answers

Zend Validator location

Do I need to save my custom Zend Validator location to "Zend/Validate"? I'd rather create a folder for all my custom validation scripts, but cannot find anything in the Zend documentation other than changing the namespace. Here is my error…
Martin Konecny
  • 57,827
  • 19
  • 139
  • 159