leo_errors/errors/
name_validation.rs

1// Copyright (C) 2019-2025 Provable Inc.
2// This file is part of the Leo library.
3
4// The Leo library is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// The Leo library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
16
17use std::fmt::{Debug, Display};
18
19create_messages!(
20    NameValidationError,
21    code_mask: 11000i32,
22    code_prefix: "NV",
23
24    @formatted
25    illegal_name {
26        args: (item_name: impl Display, item_type: impl Display, keyword: impl Display),
27        msg: format!("`{item_name}` is an invalid {item_type} name. A {item_type} cannot be called \"{keyword}\"."),
28        help: None,
29    }
30
31    @formatted
32    illegal_name_content {
33        args: (item_name: impl Display, item_type: impl Display, keyword: impl Display),
34        msg: format!("`{item_name}` is an invalid {item_type} name. A {item_type} cannot have \"{keyword}\" in its name."),
35        help: None,
36    }
37);