Added property validation

This commit is contained in:
2025-01-16 16:16:50 +01:00
parent c3c69466d4
commit d8596aa5e1
5 changed files with 101 additions and 24 deletions

View File

@@ -49,6 +49,20 @@ builder.Services.AddHopFrame(options => {
context.Table<Post>()
.Property(p => p.CreatedAt)
.ValueTemplate(() => DateTime.UtcNow);
context.Table<Post>()
.Property(p => p.Caption)
.Validator(input => {
var errors = new List<string>();
if (input is null)
errors.Add("Value cannot be null");
if (input?.Length > 10)
errors.Add("Value can only be 10 characters long");
return errors;
});
});
});