Feature #12

Validator API

Added by Davide Principi over 10 years ago. Updated over 8 years ago.

Status:CLOSEDStart date:04/07/2011
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:nethserver-nethgui
Target version:Epsilon
Resolution: NEEDINFO:

Description

Define a way to assign a validator to a parameter in a Module.

A validator object
  • Has a fluent interface with AND semantics
  • Allows composition of other validators through OR

Checking in a module if myParameter1 is an empty string OR a member of {'enabled', 'disabled'} set.

$this->declareParameter(
    'myParameter1', 
    $this->getValidator()->or(
        $this->getValidator()->empty(), 
        $this->getValidator()->memberOf('enabled', 'disabled')
    )
    ...
);


Subtasks

Feature #69: Environment for Predefined validators CLOSED


Related issues

Related to Nethgui - Feature #513: VALID_DATE and VALID_TIME validators CLOSED 09/23/2011

Associated revisions

Revision f7b9eb6b
Added by Davide Principi over 10 years ago

Refs #12. Implemented Validator API.

As proposed in #12, added NethGui_Core_Validator class and generic validator interface: NethGui_Core_ValidatorInterface.

  • Added also a unit test (incomplete).
  • Updated standard module declareParameter to deal with Validators.
  • Added getValidator() method to Standard module.

Revision 5ea79fef
Added by Davide Principi about 10 years ago

Refs #274 #12. Changed Validator API.

  • replaced getMessage() with getFailureInfo()
  • added string translation for regex validator
  • Xhtml renderer: changed access of getFullId() to "private"

Revision 5fa2df07
Added by Davide Principi almost 10 years ago

Refs #12 #478. Updated ValidationReportInterface

Two methods are now available to notify a validation error:

  • addValidationError()
    gets the validator object
  • addValidationErrorMessage()
    gets a string (and optional placeholder arguments)

Revision f59fd7d5
Added by Davide Principi almost 10 years ago

Refs #513 #69 #12. Added some validator tests.

Revision e630a49e
Added by Davide Principi over 9 years ago

System: Moved constants. Moved createValidator() in NethPlatform class. Refs #12 - Validator API

History

#1 Updated by Davide Principi over 10 years ago

  • Assignee set to Davide Principi
  • Target version set to Epsilon

#2 Updated by Davide Principi over 10 years ago

  • Start date changed from 03/25/2011 to 03/30/2011
  • Estimated time set to 12.00

#3 Updated by Davide Principi over 10 years ago

  • Status changed from NEW to ON_DEV
  • Start date changed from 03/30/2011 to 04/01/2011

#4 Updated by Davide Principi over 10 years ago

Validator cases:
  • memberOf(A) checks if value is in A set (array)
  • ipAddress checks if value is a string representing an IP address
  • inRange(n,m) checks if value is a number included in range (n,m)
  • lt(n) checks if value is less than given n
  • le(n) checks if value is less or equal to than given n
  • gt(n) checks if value is greater than given n
  • ge(n) checks if value is greater than or equal to given n
  • email() checks if value is a valid email address
  • url() checks if value is a valid URL
  • alphabetic() checks if value contains only letters
  • alphanumeric() checks if value contains only letters or numbers
  • regexp(e) checks if value matches regular expression e
  • notEmpty() checks if value is not an empty string, 0, or NULL

...

#5 Updated by Davide Principi over 10 years ago

  • % Done changed from 0 to 20

#6 Updated by Davide Principi over 10 years ago

  • Estimated time changed from 12.00 to 4.00

#7 Updated by Davide Principi over 10 years ago

  • Status changed from ON_DEV to CLOSED
  • % Done changed from 20 to 100

Also available in: Atom PDF