To use a regular expression with Laravel validation, you can use the regex rule. In this case, you can use the starts_with function to check if the part_number starts with "999", and then use a regular expression to check if the other fields are filled in.
Here's an example of how you can modify your validation rule:
$rules = [
'part_number' => 'required|starts_with:999',
'field1' => 'required_if:part_number,regex:/^999/',
'field2' => 'required_if:part_number,regex:/^999/',
'field3' => 'required_if:part_number,regex:/^999/',
'field4' => 'required_if:part_number,regex:/^999/',
];
In this example, the field1, field2, field3, and field4 fields are required if the part_number starts with "999". The regex rule is used to check if the part_number starts with "999" before checking if the other fields are filled in.
Note that the regular expression /^999/ matches any string that starts with "999". The ^ character matches the beginning of the string, and the 999 characters match the literal string "999".
Hope this helps!