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,520 points
2,664 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,840 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,840 points
11,498 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,840 points
15,995 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,840 points
5,209 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,840 points
11,927 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,840 points
23,080 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,840 points
3,016 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,840 points
2,948 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,840 points
44,888 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,840 points
1,465 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,840 points
31,288 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP