Fixed: Validation for Movie Info language

pull/10289/head
Bogdan 3 months ago
parent 0ad4d7ea9a
commit c9f28fdc4f

@ -241,6 +241,13 @@ class UISettings extends Component {
helpTextWarning={translate('MovieInfoLanguageHelpTextWarning')}
onChange={onInputChange}
{...settings.movieInfoLanguage}
errors={
languages.some((language) => language.key === settings.movieInfoLanguage.value) ?
settings.movieInfoLanguage.errors :
[
...settings.movieInfoLanguage.errors,
{ message: translate('InvalidMovieInfoLanguageLanguage') }
]}
/>
</FormGroup>

@ -5,4 +5,6 @@ export interface UiSettings {
longDateFormat: string;
timeFormat: string;
movieRuntimeFormat: string;
movieInfoLanguage: number;
uiLanguage: number;
}

@ -177,6 +177,8 @@ namespace NzbDrone.Core.Languages
}
}
private static readonly Dictionary<int, Language> Lookup = All.ToDictionary(v => v.Id);
public static Language FindById(int id)
{
if (id == 0)
@ -184,9 +186,7 @@ namespace NzbDrone.Core.Languages
return Unknown;
}
var language = All.FirstOrDefault(v => v.Id == id);
if (language == null)
if (!Lookup.TryGetValue(id, out var language))
{
throw new ArgumentException("ID does not match a known language", nameof(id));
}

@ -797,6 +797,7 @@
"InteractiveSearchResultsFailedErrorMessage": "Search failed because its {message}. Try refreshing the movie info and verify the necessary information is present before searching again.",
"Interval": "Interval",
"InvalidFormat": "Invalid Format",
"InvalidMovieInfoLanguageLanguage": "Your Movie Info Language is set to an invalid value, correct it and save your settings",
"InvalidUILanguage": "Your UI is set to an invalid language, correct it and save your settings",
"KeepAndUnmonitorMovie": "Keep and Unmonitor Movie",
"KeyboardShortcuts": "Keyboard Shortcuts",

@ -19,17 +19,21 @@ namespace Radarr.Api.V3.Config
{
_configFileProvider = configFileProvider;
SharedValidator.RuleFor(c => c.UILanguage).Custom((value, context) =>
{
if (!Language.All.Any(o => o.Id == value))
{
context.AddFailure("Invalid UI Language ID");
}
});
SharedValidator.RuleFor(c => c.MovieInfoLanguage)
.GreaterThanOrEqualTo(1)
.WithMessage("The Movie Info Language value cannot be less than 1");
SharedValidator.RuleFor(c => c.MovieInfoLanguage)
.Must(value => Language.All.Any(o => o.Id == value))
.WithMessage("Invalid Movie Info Language ID");
SharedValidator.RuleFor(c => c.UILanguage)
.GreaterThanOrEqualTo(1)
.WithMessage("The UI Language value cannot be less than 1");
SharedValidator.RuleFor(c => c.UILanguage)
.GreaterThanOrEqualTo(1)
.WithMessage("The UI Language value cannot be less than 1");
.Must(value => Language.All.Any(o => o.Id == value))
.WithMessage("Invalid UI Language ID");
}
[RestPutById]

Loading…
Cancel
Save