MCPcopy Create free account
hub / github.com/cogentcore/core / TestTextFieldValidatorValid

Function TestTextFieldValidatorValid

core/textfield_test.go:90–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestTextFieldValidatorValid(t *testing.T) {
91 b := NewBody()
92 tf := NewTextField(b).SetText("my secure password")
93 tf.SetValidator(func() error {
94 if len(tf.Text()) < 12 {
95 return errors.New("password must be at least 12 characters")
96 }
97 return nil
98 })
99 b.AssertRender(t, "text-field/validator-valid", func() {
100 tf.SendChange() // trigger validation
101 })
102}
103
104func TestTextFieldValidatorInvalid(t *testing.T) {
105 b := NewBody()

Callers

nothing calls this directly

Calls 8

AssertRenderMethod · 0.95
NewBodyFunction · 0.85
NewTextFieldFunction · 0.85
SetValidatorMethod · 0.80
SendChangeMethod · 0.80
NewMethod · 0.65
SetTextMethod · 0.45
TextMethod · 0.45

Tested by

no test coverage detected