annotate method

  1. @override
AnnotationResult annotate(
  1. dynamic cached,
  2. dynamic value,
  3. DogEngine engine
)
override

Annotates value with this validator returning an AnnotationResult. This mechanic is used to provide more information about the validation error.

Implementation

@override
AnnotationResult annotate(cached, value, DogEngine engine) {
  final isValid = validate(cached, value, engine);
  if (isValid) return AnnotationResult.empty();
  return AnnotationResult(messages: [
    AnnotationMessage(
        id: messageId, message: "Must be less than %max% (%maxExclusive%).")
  ]).withVariables({
    "max": max.toString(),
    "maxExclusive": maxExclusive ? "exclusive" : "inclusive",
  });
}