date() static public method

Checks for valid date
static public date ( string $date ) : boolean
$date string
return boolean
Ejemplo n.º 1
0
 public function validate()
 {
     $result = $this->result();
     if (empty($result)) {
         return !$this->required();
     } else {
         return v::date($result);
     }
 }
Ejemplo n.º 2
0
 public function validate()
 {
     return v::date($this->result());
 }
 public function sendBookingConfirmation()
 {
     $responseMessages = array();
     $fault = false;
     if (!v::required('email', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No email given, cheating ass bitch!');
         $fault = true;
     } else {
         if (!v::email(get('email'))) {
             $responseMessages[] = array('type' => 'error', 'message' => 'No email given, cheating ass bitch!');
             $fault = true;
         }
     }
     if (!v::required('productSelect', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No product given, cheating ass bitch!');
         $fault = true;
     }
     if (!v::required('date', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No date given, cheating ass bitch!');
         $fault = true;
     } else {
         if (!v::date(get('date'))) {
             $responseMessages[] = array('type' => 'error', 'message' => 'No valid Date, son of a bitch!');
             $fault = true;
         }
     }
     if (!v::required('name', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No name given, cheating ass bitch!');
         $fault = true;
     } else {
         if (!v::min(get('name'), 3)) {
             $responseMessages[] = array('type' => 'error', 'message' => 'At least 3 characters for a name, bitchass!');
             $fault = true;
         }
     }
     if ($fault) {
         s::set('response', $responseMessages);
         go($this->getOriginId());
     }
     $confirmationBody = self::buildMailText($this->getConfirmationText(), get());
     $ownerConfirmation = $confirmationBody . self::createBookingApprovalLink(get('email'), array(), array());
     $from = site()->contactmail()->value();
     // Send To Owner
     $confirmationMail = new Email(array('to' => self::getBookingMail(), 'from' => $from, 'subject' => 'Hey, some new booking', 'body' => $ownerConfirmation));
     // Send to User
     $userConfirmationMail = new Email(array('to' => get('email'), 'from' => $from, 'subject' => 'Hey, some new booking', 'body' => $confirmationBody));
     if ($userConfirmationMail->send() && $confirmationMail->send()) {
         $responseMessages[] = array('type' => 'success', 'message' => 'Successfully send a booking request.');
         s::set('response', $responseMessages);
     } else {
         go('error');
     }
     go($this->getOriginId());
 }
Ejemplo n.º 4
0
 public function testDate()
 {
     $this->assertTrue(v::date('2012-12-12'));
     $this->assertTrue(v::date('1970-01-01'));
     $this->assertFalse(v::date('2013-13-13'));
 }
Ejemplo n.º 5
0
 static function validate($method, $value)
 {
     switch ($method) {
         case 'date':
             return v::date($value);
             break;
         case 'url':
             return v::url($value);
             break;
         case 'email':
             return v::email($value);
             break;
         default:
             if (is_array($method)) {
                 $match = null;
                 $minlength = $maxlength = 0;
                 extract($method);
                 if ($match && !preg_match($match, $value)) {
                     return false;
                 }
                 if ($minlength && str::length($value) < $minlength) {
                     return false;
                 }
                 if ($maxlength && str::length($value) > $maxlength) {
                     return false;
                 }
             }
             break;
     }
     return true;
 }