You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type SimpleName String (pattern="[a-zA-Z_][a-zA-Z_0-9]*");
type StringTest Struct {
SimpleName name;
SimpleName opt (optional);
}
Running rdl generate go-model for this RDL produces the validation func as:
func (self*StringTest) Validate() error {
ifself.Name=="" {
returnfmt.Errorf("StringTest.name is missing but is a required field")
} else {
val:=rdl.Validate(TestSchema(), "SimpleName", self.Name)
if!val.Valid {
returnfmt.Errorf("StringTest.name does not contain a valid SimpleName (%v)", val.Error)
}
}
returnnil
}
Although opt is an optional field, it is contrained by a regex pattern that should be validated inside Validate(). I'd expect the validation func to instead be:
func (self*StringTest) Validate() error {
ifself.Name=="" {
returnfmt.Errorf("StringTest.name is missing but is a required field")
} else {
val:=rdl.Validate(TestSchema(), "SimpleName", self.Name)
if!val.Valid {
returnfmt.Errorf("StringTest.name does not contain a valid SimpleName (%v)", val.Error)
}
}
// --- additional expected code ---ifself.Opt!="" {
val:=rdl.Validate(TestSchema(), "SimpleName", self.Opt)
if!val.Valid {
returnfmt.Errorf("StringTest.opt does not contain a valid SimpleName (%v)", val.Error)
}
}
// ---------------------returnnil
}
The text was updated successfully, but these errors were encountered:
jpeirson
pushed a commit
to jpeirson/ardielle-go
that referenced
this issue
Feb 19, 2019
Take for example this RDL fragment:
Running
rdl generate go-model
for this RDL produces the validation func as:Although
opt
is an optional field, it is contrained by a regex pattern that should be validated insideValidate()
. I'd expect the validation func to instead be:The text was updated successfully, but these errors were encountered: