I'm writing a utility that validates fields on a web site. I decided I'd giveto try my hand at Behaviour Driven Development (BDD) a try. The validator utilises rules"rules" to determine if a value the user providedfield is valid.
Three different types of rules are used to validate fieldsexist:
RegexRule(fieldA field conforms to specific pattern(s))RequireRule(valueA value is present)EqualityRule(fieldA field's value equals another field'sanother's value).
A rule is tested against a value, and if. If the value does not conform to the nature of the rule, a flag is set, marking which marks the rule as erroneous. Upon callingCalling getError() on an erroneous rule, returns a string is returned detailingthat details the error. Furthermore, and the rule is reset (no longer erroneous).
Is this the correct manner of implementing BDD on this class? If not, I'd greatly appreciate advice on how I could improve on this.