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
76 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,859 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,300 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,437 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,019 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,634 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
652 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
497 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,214 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
190 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,174 views