|string> */ public function rules(): array { return [ ExternalProfile::ATTRIBUTE_SITE => [ 'required', new EnumLocalizedNameRule(ExternalProfileSite::class), ], 'code' => [ 'sometimes', Rule::when( $this->get(ExternalProfile::ATTRIBUTE_SITE) === ExternalProfileSite::MAL->localize() || $this->get(ExternalProfile::ATTRIBUTE_SITE) === ExternalProfileSite::ANILIST->localize(), ['required'] ), 'string', ], 'state' => [ Rule::when( $this->get(ExternalProfile::ATTRIBUTE_SITE) === ExternalProfileSite::MAL->localize(), ['required'] ), 'string', ], ]; } }