Skip to content
Browse files

got it working for validation rules on an ORM model

  • Loading branch information...
1 parent 51fce88 commit 1a2fa636d1bb97a6cdf30c2a27e42cfdbc2f712f Luke Armstrong committed Mar 29, 2012
Showing with 62 additions and 0 deletions.
  1. +24 −0 bootstrap.php
  2. +28 −0 classes/validation.php
  3. +4 −0 config/is_email.php
  4. +6 −0 lang/en/validation.php
View
24 bootstrap.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Fuel
+ *
+ * Fuel is a fast, lightweight, community driven PHP5 framework.
+ *
+ * @package Fuel
+ * @version 1.0
+ * @author Fuel Development Team
+ * @license MIT License
+ * @copyright 2010 - 2012 Fuel Development Team
+ * @link http://fuelphp.com
+ */
+
+require_once __DIR__.'/vendor/is_email/is_email.php';
+
+Autoloader::add_core_namespace('Is_Email');
+
+Autoloader::add_classes(array(
+ 'Is_Email\\Validation' => __DIR__.'/classes/validation.php',
+));
+
+
+/* End of file bootstrap.php */
View
28 classes/validation.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Is_Email;
+
+class Validation extends \Fuel\Core\Validation
+{
+ public function _validation_is_email($val)
+ {
+ return $this->_empty($val) || is_email($val);
+ }
+
+ public function _validation_is_emails($val)
+ {
+ if ($this->_empty($val)) {
+ return true;
+ }
+
+ $emails = explode(',', $val);
+
+ foreach ($emails as $email) {
+ if (! is_email($email)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
View
4 config/is_email.php
@@ -0,0 +1,4 @@
+<?php
+
+return array(
+);
View
6 lang/en/validation.php
@@ -0,0 +1,6 @@
+<?php
+
+return array(
+ 'is_email' => ':label must be a valid e-mail address <em>(example: username@example.com)</em>.',
+ 'is_emails' => ':label must must contain a list of valid email addresses.',
+);

0 comments on commit 1a2fa63

Please sign in to comment.
Something went wrong with that request. Please try again.