Search
 
SCRIPT & CODE EXAMPLE
 

PHP

validation sellphone laravel

One possible solution would to use regex.

'phone' => 'required|regex:/(01)[0-9]{9}/'
This will check the input starts with 01 and is followed by 9 numbers. By using regex 
you dont need the numeric or size validation rules.

If you want to reuse this validation method else where, it would be a good idea to 
create your own validation rule for validating phone numbers.

Docs: Custom Validation - https://laravel.com/docs/5.4/validation#custom-validation-rules

In your AppServiceProviders boot method:

Validator::extend('phone_number', function($attribute, $value, $parameters)
{
    return substr($value, 0, 2) == '01';
});
This will allow you to use the phone_number validation rule anywhere in your application, 
so your form validation could be:

'phone' => 'required|numeric|phone_number|size:11'
In your validator extension you could also check if the $value is numeric and 11 
characters long.
Comment

PREVIOUS NEXT
Code Example
Php :: default password when you make users in laravel 
Php :: in ImageRetriever.php line 305 at ImageRetriever-getNoPictureImage(object(Language)) in FrontController.php line 1527 
Php :: mysql.service: Start request repeated too quickly 
Php :: user input in oop php 
Php :: Comment supprimer les éléments liés à WordPress oEmbed 
Php :: display woocommerce review using specific id 
Php :: how to make category for spesific post wordpress devv 
Php :: wordrpess debugg is off but still showing 
Php :: Send Message from server laravel 
Php :: Undefined property: CI::$file 
Php :: Select All Data From MySql Database Table PHP Function 
Php :: how to get many of quensation php programming language 
Php :: cara looping abjad with array 
Php :: list database table rows plugin wordpress 
Php :: larvel still laod the local file location on production 
Php :: php array merge 
Php :: php laravel convert blob type to string 
Php :: rerender block in twig 
Php :: Laravel retrieving aggregates 
Php :: how to fetch data from database in php and display in pdf 
Php :: array_map with user functions php and parameter php 
Php :: Binance api buymarket php 
Php :: laravel showing index of 
Php :: how to remove public from url in laravel 9 
Php :: function() use() php clousure examples 
Php :: laravel best practices tutorial 
Php :: Two ways of assigning anonymous class to a variable 
Php :: laravel eloquent where date today 
Php :: php iife 
Php :: Multiple Formats with PHP DateTime::createFromFormat() 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =