在json的Angular动态中,是这样的
regConfig: FieldConfig[] = [
{
type: "input",
label: "Username",
inputType: "text",
name: "name",
validations: [
{
name: "required",
validator: Validators.required,
message: "Name Required"
},
{
name: "pattern",
validator: Validators.pattern("^[a-zA-Z]+$"),
message: "Accept only text"
}
]
}
可以很好地进行验证
但是我们正在从后端像这样从json发送响应
regConfig: FieldConfig[] = [
{
type: "input",
label: "Username",
inputType: "text",
name: "name",
validations: [
{
name: "required",
validator: "Validators.required",
message: "Name Required"
},
{
name: "pattern",
validator: Validators.pattern("^[a-zA-Z]+$"),
message: "Accept only text"
}
]
}
请参阅验证器属性。 所以我的问题是:
有没有办法像这样的验证器从后端RestController发送数据?
或者我们可以像下面这样的验证器来动态处理值:“ Validators.required”
我正在遵循这种示例