```coffeescript
Lanes.Models.Mixins.HasCodeField = {

    INVALID: /[^A-Z0-9a-z]/

    included: (klass)->
        klass::INVALID_CODE_CHARS ||= Lanes.Models.mixins.Lanes.sCodeField.INVALID

    initialize: ->
        this.on('change:code', this.upcaseCode)

    upcaseCode: ->
        this.set('code', this.get('code').toUpperCase())
}
```

Use regex to clean code strings
user
```coffeescript
DEFAULT_INVALID = /[^A-Z0-9a-z]/

Lanes.Models.Mixins.HasCodeField = {


    included: (klass) ->
        klass::INVALID_CODE_CHARS ||= DEFAULT_INVALID

    initialize: ->
        this.on('change:code', this._cleanCodeAttr)

    _cleanCodeAttr: ->
        this.set(
            'code', this.get('code').toUpperCase().replace(@INVALID_CODE_CHARS, '')
        )

    visibleIdentifier: -> @code
}
```
assistant