diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2025-10-27 09:31:48 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-01-13 15:21:31 +0100 |
| commit | a6a46c403c780144e55a337a88af49fa9aa55acd (patch) | |
| tree | 51ed900230babc6172341316fdaaaf73c0e98270 /lib | |
| parent | 6b098702c6f7df5d400b76031618506dbdda02a5 (diff) | |
| download | mihi-a6a46c403c780144e55a337a88af49fa9aa55acd.tar.gz mihi-a6a46c403c780144e55a337a88af49fa9aa55acd.zip | |
Add basic validation for verbs and pronouns
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mihi/src/lib.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/mihi/src/lib.rs b/lib/mihi/src/lib.rs index 36da6d2..78400f2 100644 --- a/lib/mihi/src/lib.rs +++ b/lib/mihi/src/lib.rs @@ -375,6 +375,19 @@ pub fn create_word(word: Word) -> Result<(), String> { )) } }, + Category::Verb => match word.conjugation_id { + Some(1..6) => { + if word.kind.as_str() != "verb" { + return Err(format!("bad kind for verb")); + } + } + Some(val) => return Err(format!("the conjugation ID '{val}' is not valid")), + None => { + return Err(String::from( + "you have to provide the conjugation ID for this verb", + )) + } + }, Category::Adverb | Category::Preposition | Category::Conjunction @@ -384,8 +397,7 @@ pub fn create_word(word: Word) -> Result<(), String> { return Err(format!("no inflection allowed for '{}'", word.category)); } } - // TODO - _ => { + Category::Unknown | Category::Pronoun => { return Err(format!( "you cannot create a word from the '{}' category", word.category |
