When following the dev course in Altinn docs, you are tasked with implementing validation according to the screenshot below.
There are some issues with formatting
Steps To Reproduce
Create a repeating group containing an Address component
Implement validation, for instance
public Task<List<ValidationIssue>> ValidateFormData(
Instance instance,
DataElement dataElement,
object data,
string language
)
{
List<ValidationIssue> issues = [];
if (data is not Skjema skjema)
throw new Exception("Invalid data type");
for (int i = 0; i < skjema.Innflytter.TidligereBosteder.Count; i++)
{
var bosted = skjema.Innflytter.TidligereBosteder[i];
if (bosted.Postnr == "1337" && !bosted.Gateadresse.Contains("🌟"))
{
issues.Add(
new ValidationIssue()
{
// InstanceId = instance.Id,
DataElementId = dataElement.Id,
Field = $"Innflytter.TidligereBosteder[{i}].Postnr",
Description = """
Vi er beæret over å motta en '1337' innbygger til Sogndal kommune!
Du må imidlertid bekrefte din uovertruffenhet ved å legge til en 🌟 i adressefeltet for å gå videre.
""",
Severity = ValidationIssueSeverity.Error
}
);
}
}
return Task.FromResult(issues);
}
Description of the bug
When following the dev course in Altinn docs, you are tasked with implementing validation according to the screenshot below. There are some issues with formatting
Steps To Reproduce
Implement validation, for instance
Additional Information
No response