validateProfile method

  1. @protected
void validateProfile(
  1. String profile
)

Profile Name Validation

Ensures the given profile is valid before use.

Rules

  • Must not be null or empty.
  • Must not start with '!' (reserved for logical negation in profile expressions).

Throws

  • IllegalArgumentException if validation fails.

Example

validateProfile('dev'); // OK
validateProfile('');    // throws
validateProfile('!test'); // throws

Implementation

@protected
void validateProfile(String profile) {
  if (profile.isEmpty) {
    throw IllegalArgumentException("Invalid profile [$profile]: must contain text");
  }
  if (profile.startsWith('!')) {
    throw IllegalArgumentException("Invalid profile [$profile]: must not begin with ! operator");
  }
}