Using multiple parameters annotations

Here is a list of all the parameters annotations and where you can use them :

AnnotationParameter kindModddel kind


Member parameter

Any modddel


Member parameter



Member parameter



Member parameter

Any modddel


Dependency parameter

Any modddel

You can annotate the same parameter with multiple annotations :

  • You can use @withGetter with any other member parameter annotation

  • You can use @NullFailure with @validParam

  • For Iterable2Entity, the member parameter can have up to two @NullFailure annotations, one for each maskNb

However :

  • You can't use @dependencyParam with any annotation reserved to member parameters

  • You can't use @NullFailure with @invalidParam : That's because @invalidParam requires a nullable parameter that is valid when it's null (See relevant section). If you want an alternative, see this section.

  • You can't use @validParam with @invalidParam

Example :

factory Person({
  @withGetter @NullFailure('identity', PersonIdentityFailure.unnamed()) required FullName? name,
  required Age age,
  @validParam @withGetter bool isAdult,
  @dependencyParam AvailabilityService availabilityService,

If you want to use both @validParam and @withGetter, you can use the shorthand @validWithGetter. Similarly, if you want to use both @invalidParam and @withGetter, you can use the shorthand @invalidWithGetter.

factory FreeArticle({
    // Same as @validParam @withGetter
    @validWithGetter required String id,
    required Description description,
    // Same as @invalidParam @withGetter
    @invalidWithGetter required InvalidPrice? price,
  }) { ...