mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-19 17:32:38 +01:00
Fixed: Validation for Movie Info language
This commit is contained in:
parent
0ad4d7ea9a
commit
c9f28fdc4f
@ -241,6 +241,13 @@ class UISettings extends Component {
|
|||||||
helpTextWarning={translate('MovieInfoLanguageHelpTextWarning')}
|
helpTextWarning={translate('MovieInfoLanguageHelpTextWarning')}
|
||||||
onChange={onInputChange}
|
onChange={onInputChange}
|
||||||
{...settings.movieInfoLanguage}
|
{...settings.movieInfoLanguage}
|
||||||
|
errors={
|
||||||
|
languages.some((language) => language.key === settings.movieInfoLanguage.value) ?
|
||||||
|
settings.movieInfoLanguage.errors :
|
||||||
|
[
|
||||||
|
...settings.movieInfoLanguage.errors,
|
||||||
|
{ message: translate('InvalidMovieInfoLanguageLanguage') }
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
|
@ -5,4 +5,6 @@ export interface UiSettings {
|
|||||||
longDateFormat: string;
|
longDateFormat: string;
|
||||||
timeFormat: string;
|
timeFormat: string;
|
||||||
movieRuntimeFormat: string;
|
movieRuntimeFormat: string;
|
||||||
|
movieInfoLanguage: number;
|
||||||
|
uiLanguage: number;
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,8 @@ public static List<Language> All
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Dictionary<int, Language> Lookup = All.ToDictionary(v => v.Id);
|
||||||
|
|
||||||
public static Language FindById(int id)
|
public static Language FindById(int id)
|
||||||
{
|
{
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
@ -184,9 +186,7 @@ public static Language FindById(int id)
|
|||||||
return Unknown;
|
return Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
var language = All.FirstOrDefault(v => v.Id == id);
|
if (!Lookup.TryGetValue(id, out var language))
|
||||||
|
|
||||||
if (language == null)
|
|
||||||
{
|
{
|
||||||
throw new ArgumentException("ID does not match a known language", nameof(id));
|
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.",
|
"InteractiveSearchResultsFailedErrorMessage": "Search failed because its {message}. Try refreshing the movie info and verify the necessary information is present before searching again.",
|
||||||
"Interval": "Interval",
|
"Interval": "Interval",
|
||||||
"InvalidFormat": "Invalid Format",
|
"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",
|
"InvalidUILanguage": "Your UI is set to an invalid language, correct it and save your settings",
|
||||||
"KeepAndUnmonitorMovie": "Keep and Unmonitor Movie",
|
"KeepAndUnmonitorMovie": "Keep and Unmonitor Movie",
|
||||||
"KeyboardShortcuts": "Keyboard Shortcuts",
|
"KeyboardShortcuts": "Keyboard Shortcuts",
|
||||||
|
@ -19,17 +19,21 @@ public UiConfigController(IConfigFileProvider configFileProvider, IConfigService
|
|||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.UILanguage).Custom((value, context) =>
|
SharedValidator.RuleFor(c => c.MovieInfoLanguage)
|
||||||
{
|
.GreaterThanOrEqualTo(1)
|
||||||
if (!Language.All.Any(o => o.Id == value))
|
.WithMessage("The Movie Info Language value cannot be less than 1");
|
||||||
{
|
|
||||||
context.AddFailure("Invalid UI Language ID");
|
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)
|
SharedValidator.RuleFor(c => c.UILanguage)
|
||||||
.GreaterThanOrEqualTo(1)
|
.GreaterThanOrEqualTo(1)
|
||||||
.WithMessage("The UI Language value cannot be less than 1");
|
.WithMessage("The UI Language value cannot be less than 1");
|
||||||
|
|
||||||
|
SharedValidator.RuleFor(c => c.UILanguage)
|
||||||
|
.Must(value => Language.All.Any(o => o.Id == value))
|
||||||
|
.WithMessage("Invalid UI Language ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
[RestPutById]
|
[RestPutById]
|
||||||
|
Loading…
Reference in New Issue
Block a user