Validate query string and value based on if query string is present

Scenario:

Validate query string for null or empty if only it exists

Solution:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
     public bool validate()
            {
                if (queryStringCollection.AllKeys.Any(k => k.StartsWith("field_name")))
                {
                    fieldValue = queryStringCollection.Get("field_name");
                    if (string.IsNullOrWhiteSpace(fieldValue) )
                    {
                        throw customeError;
                    }
                }
            }  

No comments:

Post a Comment

Move Github Sub Repository back to main repo

 -- delete .gitmodules git rm --cached MyProject/Core git commit -m 'Remove myproject_core submodule' rm -rf MyProject/Core git remo...