Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: accept pointers rather than values for the validate_nnn() functions #12

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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()
}

Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(_) => {
Expand Down
Loading