Skip to content

This package contains several "primitive" types that are used throughout the rest of the Types package.

License

Notifications You must be signed in to change notification settings

dgmjr-io/Primitives

Repository files navigation

authors date description keywords license slug title type lastmod project version
dgmjr
2023-07-02 20:00:10 UTC
This package contains several *primitive* types that are used throughout the rest of the Types package.
DGMJR-IO
emailaddress
int24
primitives
phonenumber
objectid
types
uri
urn
url
xri
iri
MIT
primitives
DGMJR-IO Primitives
readme
2023-07-02 22:36:04 UTC
Dgmjr.Types
0.0.1

DGMJR-IO Primitives

This package contains several "primitive" types that are used throughout the rest of the Types package.

Domain Data Types

Email Address Value Object

Overview

The EmailAddress struct represents an email address value. It aims to encapsulate email address parsing, validation, and formatting logic in a reusable way.

Key features:

  • Implements value object interfaces like IEquatable, IComparable, etc.
  • Leverages regex for validation.
  • Provides implicit conversions to/from string.
  • Includes constants for common scenarios.
  • Generates a mailto: URI.

Usage

EmailAddress can be used anywhere an email address value is needed:

var email = EmailAddress.From("[email protected]");

if (!email.IsEmpty) {
  // use email
}

Phone Number Value Object

This file contains the implementation of the PhoneNumber value object for representing phone numbers.

Overview

The PhoneNumber struct encapsulates parsing, validation, and formatting of phone numbers in a reusable way.

Key features:

  • Implements IRegexValueObject for parsing and validation.
  • Leverages libphonenumber for parsing into components.
  • Provides implicit conversions to/from string.
  • Generates a tel: URI from the number.
  • Includes constants like Empty, ExampleValue, etc.

Usage

PhoneNumber can be used anywhere a parsed, validated phone number value is needed:

var number = PhoneNumber.From("+12025551234");

Console.WriteLine(number.IsEmpty); // true
Console.WriteLine(number.ToString()); // +12025551234

Object ID Value Object

  • ObjectId - A 24-hex-digit (96-bit) string

This directory contains the implementation of the ObjectId value object.

Overview

The ObjectId struct represents an ObjectId value commonly used in MongoDB. It aims to encapsulate ObjectId parsing, validation, and formatting logic in a reusable way.

Key features:

  • Implements value object interfaces like IEquatable, IComparable, etc.
  • Leverages regex for validation.
  • Provides static factory methods like Parse and TryParse.
  • Generates a URN identifier URI.
  • Includes constants for common scenarios.

Usage

ObjectId can be used anywhere a MongoDB ObjectId value is needed:

var id = ObjectId.TryParse("61f7c3692093f4d09f000123", out var oid) ? oid : ObjectId.Empty;

if (id.IsEmpty) {
  // use id
}

Numerics

  • Int24 - a 24-bit signed integer (alias: i24)
  • UInt24 - a 24-bit unsigned integer (alias: ui24)

The X Resource Ys

These are a collection of X Resource Ys.

  • iri - An internationalized resource identifier
  • uri - A uniform resource identifier
  • url - A uniform resource locator
  • urn - A uniform resource name
  • xri - An eXtensble resource identifier

About

This package contains several "primitive" types that are used throughout the rest of the Types package.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages