Skip to content

Commit fa5437a

Browse files
committed
chore: accept pointers rather than values for the validate_nnn() functions
1 parent 142f711 commit fa5437a

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod validate;
88
#[wasm_bindgen]
99
pub fn validate_base(js_config: JsValue, base: String) -> JsValue {
1010
let config: validate::LanguageConfig = serde_wasm_bindgen::from_value(js_config).unwrap();
11-
let response = validate::validate_base(config, base);
11+
let response = validate::validate_base(&config, &base);
1212
serde_wasm_bindgen::to_value(&response).unwrap()
1313
}
1414

@@ -20,7 +20,7 @@ pub fn validate_translation(
2020
translation: String,
2121
) -> JsValue {
2222
let config: validate::LanguageConfig = serde_wasm_bindgen::from_value(js_config).unwrap();
23-
let response = validate::validate_translation(config, base, case, translation);
23+
let response = validate::validate_translation(&config, &base, &case, &translation);
2424
serde_wasm_bindgen::to_value(&response).unwrap()
2525
}
2626

src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ fn main() {
3232

3333
let result = match args.translation {
3434
Some(translation) => validate::validate_translation(
35-
config,
36-
args.base,
37-
args.case.unwrap_or(String::from("default")),
38-
translation,
35+
&config,
36+
&args.base,
37+
&args.case.unwrap_or(String::from("default")),
38+
&translation,
3939
),
40-
None => validate::validate_base(config, args.base),
40+
None => validate::validate_base(&config, &args.base),
4141
};
4242

4343
for err in &result.errors {

src/validate.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Serialize for Severity {
6666
*
6767
* @returns A normalized form of the base string for translators, and a list of error messages, if the base is invalid.
6868
*/
69-
pub fn validate_base(config: LanguageConfig, base: String) -> ValidationResult {
69+
pub fn validate_base(config: &LanguageConfig, base: &String) -> ValidationResult {
7070
let mut base = match ParsedString::parse(&base) {
7171
Err(err) => {
7272
return ValidationResult {
@@ -109,10 +109,10 @@ pub fn validate_base(config: LanguageConfig, base: String) -> ValidationResult {
109109
* @returns A normalized form of the translation, and a list of error messages, if the translation is invalid.
110110
*/
111111
pub fn validate_translation(
112-
config: LanguageConfig,
113-
base: String,
114-
case: String,
115-
translation: String,
112+
config: &LanguageConfig,
113+
base: &String,
114+
case: &String,
115+
translation: &String,
116116
) -> ValidationResult {
117117
let base = match ParsedString::parse(&base) {
118118
Err(_) => {

0 commit comments

Comments
 (0)