Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested rule - combine dot notation and nested structure #6

Closed
arogachev opened this issue Apr 13, 2022 · 1 comment
Closed

Nested rule - combine dot notation and nested structure #6

arogachev opened this issue Apr 13, 2022 · 1 comment
Assignees
Labels

Comments

@arogachev
Copy link
Contributor

arogachev commented Apr 13, 2022

Moved from yiisoft/validator#200.

Initially reported by @a6colute.

@arogachev arogachev added the type:bug Bug label Apr 13, 2022
@arogachev arogachev self-assigned this Apr 13, 2022
@vjik vjik transferred this issue from yiisoft/form Dec 3, 2023
@vjik
Copy link
Member

vjik commented Dec 4, 2023

 'body.shipping' => [
      Required::rule(),
      Nested::rule([
          'phone' => [MatchRegularExpression::rule('/^\+\d{11}$/')],
      ]),
],

It's not correct rules format. Dot notation don't support in rules. It's allow in Nested only and o far only for public properties.

Correct rules:

'body' => new Nested([
	'shipping' => [
		new Required(),
		new Nested([
		  'phone' => new Regex('/^\+\d{11}$/'),
		]),
	]
]),

See test here: #10

@vjik vjik closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants