Fluent field descriptions along of Attributes
ddjerqq opened this issue · comments
10x developer commented
this library will eventually have Fluent Config support
public class UserCreateCommand
{
public string Name { get; set; }
public string Email { get; set; }
public int Salary { get; set; }
}
public class UserCreateConfig : IQuickFOrmConfig<UserCreateCommand>
{
public UserCreateConfig()
{
FieldCssClassProvider = ..;
ValidationCssClassProvider = ..;
FormatFor(model => model.Name)
.Required()
.RegexPattern("^[a-zA-Z]{3,32}$")
.Editable(true) // default
.Label("Name")
.Description("The name of the user")
.Placeholder("Enter the name of the user...")
.ValidFeedback("Looks good!")
.InvalidFeedback("Please enter a name.");
FormatFor(model => model.Email)
.Required()
.EditorClass("my-3")
.LabelClass("form-label text-danger")
.InputClass("form-control")
.DataType(DataType.EmailAddress);
FormatFor(model => model.Salary)
.Range(0, 100)
.InvalidFeedback("Please enter a number between 0 and 100.");
}
}