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

allowing international letters like æøå #12

Conversation

samuelsen
Copy link
Contributor

Ref issue: #11 (comment)
In the latest version of the library the following code has been introduced to validate input names:

public static string NormalizeVariableName(string name)

For out part this brakes because of using Norwegian letters like æ, ø, å, within the DMN files, and also as input params to the library.

A better solution would probably be to use the .net function:

public static string NormalizeVariableName(string name)
{
    var retVal = name?.Trim().Replace(' ', '_');

    if (string.IsNullOrWhiteSpace(retVal))
        throw new ArgumentException($"Variable name is null or empty",nameof(name));

    if (retVal.Any(c => char.IsLetter(c) || char.IsDigit(c)  || c == '_')))
        throw new ArgumentException($"Variable name '{name}' contains invalid character", nameof(name));

    if (!char.IsLetter(retVal[0])
        throw new ArgumentException($"Variable name '{nameof(name)}' must start with letter", nameof(name));

    return retVal;
}

Copy link
Owner

@adamecr adamecr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Simen, the idea seems to be ok, there are just some minor syntax issues in the PR (see the comments).
When I did the corrections, it compiles fine and it also pass all tests. I'll think a bit about possible impacts, but so far don't see any

@adamecr adamecr added the bug Something isn't working label Jan 6, 2022
Copy link
Owner

@adamecr adamecr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelsen thanks for the update, it's passing the compilation and tests fine now

@adamecr
Copy link
Owner

adamecr commented Jan 7, 2022

I'm building some additional tests to ensure the proper/expected behavior when using the non-ASCII letters in input and variables before merging the PR (will report the progress at related issue #11 )

cc @samuelsen

@adamecr adamecr merged commit 8175808 into adamecr:master Jan 8, 2022
@samuelsen samuelsen deleted the bug/NormalizeVariableName(string-name)-international-letters branch January 8, 2022 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants