(value any)
| 164 | } |
| 165 | |
| 166 | func (validator *collectionValidator) checkUniqueName(value any) error { |
| 167 | v, _ := value.(string) |
| 168 | |
| 169 | // ensure unique collection name |
| 170 | if !validator.app.IsCollectionNameUnique(v, validator.original.Id) { |
| 171 | return validation.NewError("validation_collection_name_exists", "Collection name must be unique (case insensitive).") |
| 172 | } |
| 173 | |
| 174 | // ensure that the collection name doesn't collide with the id of any collection |
| 175 | dummyCollection := &Collection{} |
| 176 | if validator.app.ModelQuery(dummyCollection).Model(v, dummyCollection) == nil { |
| 177 | return validation.NewError("validation_collection_name_id_duplicate", "The name must not match an existing collection id.") |
| 178 | } |
| 179 | |
| 180 | // ensure that there is no existing internal table with the provided name |
| 181 | if validator.original.Name != v && // has changed |
| 182 | validator.app.IsCollectionNameUnique(v) && // is not a collection (in case it was presaved) |
| 183 | validator.app.HasTable(v) { |
| 184 | return validation.NewError("validation_collection_name_invalid", "The name shouldn't match with an existing internal table.") |
| 185 | } |
| 186 | |
| 187 | return nil |
| 188 | } |
| 189 | |
| 190 | func (validator *collectionValidator) ensureNoSystemNameChange(value any) error { |
| 191 | v, _ := value.(string) |
nothing calls this directly
no test coverage detected