Ft.Datafangst.Utils 1.6.16

dotnet add package Ft.Datafangst.Utils --version 1.6.16
NuGet\Install-Package Ft.Datafangst.Utils -Version 1.6.16
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ft.Datafangst.Utils" Version="1.6.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ft.Datafangst.Utils --version 1.6.16
#r "nuget: Ft.Datafangst.Utils, 1.6.16"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Ft.Datafangst.Utils as a Cake Addin
#addin nuget:?package=Ft.Datafangst.Utils&version=1.6.16

// Install Ft.Datafangst.Utils as a Cake Tool
#tool nuget:?package=Ft.Datafangst.Utils&version=1.6.16

Utilities

Contains various utilities related to development of Ft.Datafangst logic.

Install or update a package to project

The dotnet add package command installs the latest version of the package unless you specify a different version.

dotnet add package Ft.Datafangst.Utils

NB! Must be in the project folder that it is to be added to!

To install a specific version of a NuGet package, use the optional -v or --version switch:

dotnet add package Ft.Datafangst.Utils --version 1.0.0

Use the dotnet remove package command to remove a package reference from the project file.

dotnet remove package Ft.Datafangst.Utils

To restore a package Open a command line and switch to the directory that contains your project file. Then run dotnet restore.

dotnet restore

ModelStateDictionaryExtension

IsConditionInError

Adds a specified errorMessage or appends FIXED to the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateEntry.Errors instance that is associated with the specified key depending on the state.

  • Param:
    • modelStateDic: Represents the outcome of binding values from an HTTP request to an action method. This includes associated validation details.
    • state: Condition to evaluate for determining the error state.
    • key: Identifier for the ModelStateEntry where the errors is to be added.
    • errorMsg: Message to add or update. Basic Example in C#
ModelStateDictionary validationResults = new ModelStateDictionary();
var key = "organisasjonsnummer";
var errorMsg = "testError";
bool conditionIsError = 2 + 1 == 4;  // Evaluates to false.
validationResults.IsConditionInError(conditionIsError, key, errorMsg);

StringExtensions

IsOrganizationNumberValid

Validates if a given string is a valid Organization (Business Registration) Number.

  • Param:
    • organizationNumber: The organization (Business Registration) number to validate. This should be a 9-digit numeric string.
  • Returns:
    • True if Organization (Business Registration) number is of a valid format, otherwise false. Basic Example in C#
bool isValid = "123456789".IsOrganizationNumberValid(); // Returns true
bool isNotValid = "123".IsOrganizationNumberValid();   // Returns false

IsIsinValid

Validates whether a given string adheres to the ISIN code format.

  • Param:
    • isinCode: The string representation of the ISIN code for validation.
  • Returns:
    • True if the ISIN code is of a valid format, otherwise false. Basic Example in C#
bool isValid = "No1234567890"IsIsinValid());  // Returns true
bool isNotValid = "No123".IsIsinValid();          // Returns false

IsLeiValid

Validates whether the given string conforms to the Legal Entity Identifier (LEI) standard.

  • Param: -lei: An LEI is a 20-character alphanumeric code that follows a specific format. (ISO 17442: The Global Standard) It consists of four parts: - Characters 1-4: Prefix used to ensure the uniqueness among codes from LEI issuers (Local Operating Units or LOUs). - Characters 5-18: Entity-specific part of the code generated and assigned by LOUs according to transparent, sound and robust allocation policies. As required by ISO 17442, it contains no embedded intelligence. - Characters 19-20: Two check digits as described in the ISO 17442 standard.
  • Returns:
    • True if the Legal Entity Identifier (LEI) is of a valid format, otherwise false. Basic Example in C#
bool isValid = "123400ABCDE7810FGH07".IsLeiValid(); // Returns true
bool isNotValid = "7ZW8QJWVPR4P1J".IsLeiValid(); // Returns false

IsNorwegianSosialSecurityNumberValidFormatted

Validates if a norwegian sosial security number is in a valid format or not. Checks length of the string and the date part. It is also compatible with D and H numbers. (D and H numbers are sosial security number for people that are not norwegian citizens at birth)

  • Param:
    • sosialSecurityNumber: Norwegian Sosial Security Number
  • Return:
    • True if the sosial security number is of a valid format, otherwise false.
bool isValid = "31012312345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns true
bool isValid = "71012312345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns true
bool isValid = "31412312345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns true
bool isValid = "29022012345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns true
bool isNotValid = "31022312345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns false
bool isNotValid = "71412312345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns false
bool isNotValid = "33412312345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns false
bool isNotValid = "29022312345".IsNorwegianSosialSecurityNumberValidFormatted(); // Returns false because this was not a leap year.



### ConvertLanguageStringToNumeric
Transforms a two-letter language code (e.g., "nb") into its corresponding numeric value. If no valid code is provided or found, it defaults to English (1033).
- Param:
    - language: Two-character language code (e.g., "nb" for Norwegian).
         - "nb": Returns 1044
         - "nn": Returns 2068
         - Any other value or null: Defaults to 1033
- Return: 
    - A numeric representation of the provided language code.

Basic Example in C#
```C#
     1044 = "nb".ConvertLanguageStringToNumeric();
     1033 = null.ConvertLanguageStringToNumeric();

GetLanguageAsNumeric

Gets the language that is set up with the user profile and converts it to a numeric value. If no valid code is provided or found, it defaults to English (1033).

  • Param:
    • userProfile: User profile to get language form
  • Return:
    • A numeric representation of the provided language code.

SetPeriode

Configures the period based on the period type and optionally, the year.

  • Param:
    • periodeType: A code representing specific times within a year.
      • H1: 1. Halvår
      • H2: 2. Halvår
      • Q1: 1. Kvartal
      • Q2: 2. Kvartal
      • Q3: 3. Kvartal
      • Q4: 4. Kvartal
      • M1: Januar
      • M2: Februar
      • M3: Mars
      • M4: April
      • M5: Mai
      • M6: Juni
      • M7: Juli
      • M8: August
      • M9: September
      • M10: Oktober
      • M11: November
      • M12: Desember
      • Y: År
      • O: Løpende rapportering
    • year (Optional): The specific year for the period.
  • Return:
    • A string combined from the userProfile code and the year.

Basic Example in C#

     "1. halvår 2023" = "H1".SetPeriode(2023);
     "1. halvår" = "H1".SetPeriode();
     "År 2023" = null.SetPeriode("2023");
     "" = null.SetPeriode("");

StringValuesExtension

ContainsSpecificStringValue

Checks if the StringValues contains a specific string value. Typical use of this will be to check if a http header element contains a specific string.

  • Param:
    • stringValues: StringValues to check in.
    • containedString: Specific string value to check for
  • Return:
    • True if specific string value is found, otherwise false.

Basic Example in C#

    var stringValues = new StringValues(new[] {"4-1-RadioButtons", "4-6-1-1-RadioButtons-0-0", "4-2-1-Input"});

    true = stringValues.ContainsSpecificStringValue("4-2-1-Input");
    false = stringValues.ContainsSpecificStringValue("4-2-0-Input");

HttpContextAccessorExtension

ContainsSpecificStringValue

Checks if a HttpContextAccessor element contains a specific string value in its Header. Typical use of this will be to check if a http header element contains a specific string.

  • Param:
    • httpContextAccessor: HttpContextAccessor to check if has the value in.
    • key: The string of the Key that belongs to the StringValues to check in.
    • containedString: Specific string value to check for.
  • Return:
    • True if specific string value is found, otherwise false.

Basic Example in C#

    var key = "X-ComponentId";
    var result = httpContextAccessor.Object.ContainsSpecificStringValue(key, "4-1-RadioButtons");
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.16 163 3/11/2024
1.6.14 144 2/5/2024
1.6.13 90 2/1/2024
1.6.12 267 1/4/2024
1.6.11 135 12/19/2023
1.6.10 270 11/21/2023
1.6.9 160 11/14/2023
1.6.8 172 10/30/2023
1.6.7 152 10/26/2023
1.6.6 112 10/25/2023
1.6.4 145 10/19/2023
1.6.3 141 10/18/2023
1.6.2 154 10/12/2023
1.6.1 169 9/21/2023
1.6.0 181 8/31/2023
1.5.3 390 5/25/2023
1.5.2 337 4/4/2023
1.5.0 333 3/16/2023
1.4.0 310 3/8/2023
1.3.0 264 3/2/2023
1.2.1 242 3/2/2023
1.2.0 247 3/2/2023
1.1.2 221 3/2/2023
1.1.1 233 3/2/2023
1.0.5 254 2/14/2023
1.0.4 259 2/14/2023