TimeoutPage.validate()#

TimeoutPage.validate() bool[source]#

Returns True, if the validation checks pass, False otherwise.

Can be overloaded for custom validation behavior.

Returns

A boolean, indicating whether validation was successful.

Return type

bool

Notes

The method must return True if validation is OK and False if validation fails. You can use ExperimentSession.post_message() to post a message for participants that will be displayed if validation fails.

Examples

import alfred3 as al
exp = al.Experiment()

@exp.member
class Demo(al.Page):

    def on_exp_access(self):
        self += al.NumberEntry(name="e1", force_input=True)
        self += al.NumberEntry(name="e2", force_input=True)

    def validate(self):
        e1 = int(self.exp.values.get("e1"))
        e2 = int(self.exp.values.get("e2"))

        if not (e1 + e2) > 10:
            self.exp.post_message(
                msg="The sum of your input values must be >10",
                level="danger"
                )
            return False

        return True