()
| 270 | } |
| 271 | |
| 272 | func (o UnaryOperation) validate() error { |
| 273 | if err := o.Expression.validate(); err != nil { |
| 274 | return err |
| 275 | } |
| 276 | |
| 277 | // Disallow intrinsic=nil |
| 278 | if o.Op == OpNotExists { |
| 279 | if attr, ok := o.Expression.(Attribute); ok { |
| 280 | switch { |
| 281 | case attr.Intrinsic != IntrinsicNone: |
| 282 | return fmt.Errorf("%s=nil is not valid because intrinsics cannot be nil", attr.String()) |
| 283 | case attr == NewScopedAttribute(AttributeScopeResource, false, "service.name"): |
| 284 | return fmt.Errorf("%s=nil is not valid because resource.service.name cannot be nil", attr.String()) |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | t := o.Expression.impliedType() |
| 290 | if t == TypeAttribute { |
| 291 | return nil |
| 292 | } |
| 293 | |
| 294 | if !o.Op.unaryTypesValid(t) { |
| 295 | return fmt.Errorf("illegal operation for the given type: %s", o.String()) |
| 296 | } |
| 297 | |
| 298 | return nil |
| 299 | } |
| 300 | |
| 301 | func (s Static) validate() error { |
| 302 | return nil |
no test coverage detected