Ignore:
Timestamp:
03/27/14 14:44:36 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Return to using truly ISO formatted dates, including milliseconds.
  • Also set constraint on surveyrun dates when value is initially set.
  • Separate runs & results from surveys and questions.
  • Moved date & email format to schema itself.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/server/util/validator.js

    r493 r531  
    11var tv4 = require('tv4');
    2 
    3 // from: http://www.w3.org/TR/html5/forms.html#valid-e-mail-address
    4 var html5EmailRe = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
    5 var datetimeRe = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z/;
    6 
    7 tv4.addFormat({
    8     email: function(data){
    9         if ( typeof data === "string" && html5EmailRe.test(data) ) {
    10             return null;
    11         } else {
    12             return "Probably an invalid email address.";
    13         }
    14     },
    15     datetime: function(data){
    16         if ( typeof data === "string" && datetimeRe.test(data) ) {
    17             return null;
    18         } else {
    19             return "Invalid timestamp.";
    20         }
    21     }
    22 });
    232
    243module.exports = function() {
Note: See TracChangeset for help on using the changeset viewer.