gitignore_template_generator/validator/impls.rs
1use crate::constant;
2
3use super::api::CliArgsValidator;
4
5/// Default implementation of cli args validator.
6///
7/// Can be used directly as part of [`clap::Arg::value_parser`].
8pub struct DefaultCliArgsValidator;
9
10impl CliArgsValidator for DefaultCliArgsValidator {
11 /// Checks if given value contains commas.
12 ///
13 /// Returns [`constant::error_messages::COMMAS_NOT_ALLOWED`] if any commas
14 /// found.
15 ///
16 /// See [`CliArgsValidator`] for more infos.
17 fn has_no_commas(value: &str) -> Result<String, String> {
18 if value.contains(',') {
19 Err(String::from(constant::error_messages::COMMAS_NOT_ALLOWED))
20 } else {
21 Ok(value.to_string())
22 }
23 }
24}