How to validate exact words in Laravel

0 votes

Does the validation class in Laravel validate exact words?

eg

$rules = [
           "field" => "hello"
         ]

Where the value of the field must be "hello".

Dec 4, 2020 in Laravel by kartik
• 37,490 points
84 views

1 answer to this question.

0 votes

Hello,

Try this code:

// option one: 'in' takes a comma-separated list of acceptable values
$rules = [
    'field' => 'in:hello',
];

// option two: write a matching regular expression
$rules = [
    'field' => 'regex:^hello$',
];
answered Dec 4, 2020 by Niroj
• 82,580 points

Related Questions In Laravel

0 votes
1 answer

How to validate Route Parameters in Laravel?

Hello @kartik, The issue is route parameters aren't ...READ MORE

answered Sep 25, 2020 in Laravel by Niroj
• 82,580 points
1,875 views
0 votes
1 answer

How to validate an input field if value is not null in Laravel?

Hello @kartik, try using nullable as a rule 'password' ...READ MORE

answered Sep 25, 2020 in Laravel by Niroj
• 82,580 points
2,335 views
0 votes
1 answer

How to pass URL param in Laravel?

Hello, First you have to go to routes ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,580 points
2,451 views
0 votes
1 answer

How to pass data through URL and access through controller in Laravel?

Hello, You can  first refer how to  Create controller through ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,580 points
5,044 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,580 points
5,669 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,580 points
660 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,580 points
503 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,580 points
6,246 views
0 votes
1 answer

Explain validations in laravel and How to validate my application incoming data?

Hey @kartik, In Programming validations are a handy ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,580 points
191 views
0 votes
1 answer

How to validate array in Laravel?

Hello @kartik, you can call validate() method directly ...READ MORE

answered Aug 10, 2020 in Laravel by Niroj
• 82,580 points
6,219 views