Skip to content
This repository was archived by the owner on Jun 7, 2019. It is now read-only.

A toolset to validate, format, parse and generate structured (organisational, government, ...) numbers/codes.

License

Notifications You must be signed in to change notification settings

KodeFoxx-Archives/deprecated-Numaris

Repository files navigation

Numaris

A toolset to validate, format, parse and generate structured (organisational, government, ...) numbers/codes.

Build status

Build status Test status
Build status Test status

How & what?

Numaris is build around the idea of a specification. This means that you make a marker class for your number, e.g. IbanNumberSpecification. You then implement the specification further by making specifications for fields, e.g. CheckDigitsFieldSpecification. Those field specifications carry an order, which is used for parsing, validation etc.. In essence, you build up a number in code, or in other words you "specify" your number characteristics.

The API is designed for flexible use of Dependency Injection. Every formatter, parser, generator you create you can link to either a NumberSpecification or a FieldSpecification. This makes it that you have to implement as little as possible and can leave the boilerplate code behind, and focus on the real implementation details.

Formatting

Formatters have a method Format(string). This method first uses the parser defined for the number specification. If there is no number defined it will pass it on the the Format(string[]) method. The latter method does the formatting work, where it takes each string and formats it accordingly.

Example

Parsing

StringParsers are the parsers that are used intsensively inside the API, although they're optional, if you want to use Formatting for example it is recommended to implement a StringParser for your NumberSpecification. Their purpose is to parse a input string into an array of strings which either a Formatter or Validator can use later on in the process.

Example

Validation

Validators have a method Validate(string) which, like the formatters, calls the StringParses that's defined for the specification and then passes those results on to the Validate(string[]) method. A validator returns a ValidationResults, which is an accumulation of IPartialValidationResults, those are linked to field specifications and either return true/false and optionally have a message. If valid and contains a message, then this is seen as a "warning".

It has to be noted that each field has it's own validator, a IFieldValidator<NumberSpecification> (e.g. see CheckDigitsFieldValidator.cs). For checking data accross multiple fields one defines an IMultipleFieldsValidator<NumberSpecification> (e.g. see CheckDigitsMultipleFieldsValidator.cs).

Example

Generation

Todo

About

A toolset to validate, format, parse and generate structured (organisational, government, ...) numbers/codes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages