]> _ Git - cubist_cms-back.git/commitdiff
wip #3169 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Oct 2019 14:44:59 +0000 (15:44 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Oct 2019 14:44:59 +0000 (15:44 +0100)
src/app/Validation/Rules/PhoneNumber.php [new file with mode: 0644]

diff --git a/src/app/Validation/Rules/PhoneNumber.php b/src/app/Validation/Rules/PhoneNumber.php
new file mode 100644 (file)
index 0000000..ab85a2e
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Validation\Rules;
+
+use Illuminate\Contracts\Validation\Rule as BaseRule;
+
+class PhoneNumber implements BaseRule
+{
+    public function passes($attribute, $value)
+    {
+        return preg_match("/^[0-9 \+\.\-\(\)]{10,}$/", $value);
+    }
+    /**
+     * Get the validation error message.
+     *
+     * @param none.
+     * @return string.
+     *
+     **/
+    public function message()
+    {
+        return Helper::getLocalizedErrorMessage(
+            'phone_number',
+            'The :attribute must be a valid telephone number (7 - 15 digits in length)'
+        );
+    }
+}