diff --git a/src/lib.rs b/src/lib.rs index bd5fdd0..acfb08e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ pub mod validate; #[wasm_bindgen] pub fn validate_base(js_config: JsValue, base: String) -> JsValue { let config: validate::LanguageConfig = serde_wasm_bindgen::from_value(js_config).unwrap(); - let response = validate::validate_base(config, base); + let response = validate::validate_base(&config, &base); serde_wasm_bindgen::to_value(&response).unwrap() } @@ -20,7 +20,7 @@ pub fn validate_translation( translation: String, ) -> JsValue { let config: validate::LanguageConfig = serde_wasm_bindgen::from_value(js_config).unwrap(); - let response = validate::validate_translation(config, base, case, translation); + let response = validate::validate_translation(&config, &base, &case, &translation); serde_wasm_bindgen::to_value(&response).unwrap() } diff --git a/src/main.rs b/src/main.rs index 6b65a9f..bf0cb38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,12 +32,12 @@ fn main() { let result = match args.translation { Some(translation) => validate::validate_translation( - config, - args.base, - args.case.unwrap_or(String::from("default")), - translation, + &config, + &args.base, + &args.case.unwrap_or(String::from("default")), + &translation, ), - None => validate::validate_base(config, args.base), + None => validate::validate_base(&config, &args.base), }; for err in &result.errors { diff --git a/src/validate.rs b/src/validate.rs index cb888e0..e69ce64 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -66,7 +66,7 @@ impl Serialize for Severity { * * @returns A normalized form of the base string for translators, and a list of error messages, if the base is invalid. */ -pub fn validate_base(config: LanguageConfig, base: String) -> ValidationResult { +pub fn validate_base(config: &LanguageConfig, base: &String) -> ValidationResult { let mut base = match ParsedString::parse(&base) { Err(err) => { return ValidationResult { @@ -109,10 +109,10 @@ pub fn validate_base(config: LanguageConfig, base: String) -> ValidationResult { * @returns A normalized form of the translation, and a list of error messages, if the translation is invalid. */ pub fn validate_translation( - config: LanguageConfig, - base: String, - case: String, - translation: String, + config: &LanguageConfig, + base: &String, + case: &String, + translation: &String, ) -> ValidationResult { let base = match ParsedString::parse(&base) { Err(_) => {