/// <summary> /// Validates a URL Picker state against the settings, to ensure there has been no trickery /// client-side /// </summary> /// <param name="state">The state DTO to validate against</param> /// <returns>Whether the state is valid</returns> public bool ValidateState(UrlPickerState state) { // Invalid if: // 1. If the mode is not allowed (or) // 2. The state fails its own validation if (!AllowedModes.Contains(state.Mode) || !state.Validates()) { return(false); } return(true); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (AllowedModes.Count == 0) { yield return(new ValidationResult("You must select at least one allowed mode")); } if (!AllowedModes.Contains(DefaultMode)) { yield return(new ValidationResult("The default mode must be chosen from the allowed modes")); } }