SkillAgentSearch skills...

FPrimitive

.NET project to help developers to build a correct and more safe domain model

Install / Use

/learn @stijnmoreels/FPrimitive
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

NuGet Badge codecov

FPrimitive

FPrimitive is a .NET project to help developers build a correct and more secure domain model by providing building blocks, standard types and trust boundaries.

<img src="/docs/img/logo.png" width=100 height=100 alt="logo" />

Build Status

| Mono | .NET | | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | Build Status | .NET Build status |

Documentation

The project has a wiki page with further information and some additional resources are also listed here:

Examples

The project contains several reusable building blocks to make your domain model more correct and therefore more secure.

open FPrimitive

/// Composible specifications for your domain types:
type NonEmptyString =
  private NonEmptyString of string with
    static member create x : Result<NonEmptyString, Map<string, string list>> =
      Spec.def<string>
      |> Spec.notNull "should not be null"
      |> Spec.notEmpty "should not be empty"
      |> Spec.createModel NonEmptyString x

/// ...also available as computation expression.
type NonEmptyList<'a> =
  private NonEmptyList of 'a list with
    static member create xs : Result<NonEmptyList<'a>, Map<string, string list>> =
      specModel NonEmptyList xs {
        nonEmpty "list should not be empty"
        lengthBetween 1 10 "list length should be between 1-10" }

/// Access controllers for your critical application resources:
let uncontrolled_critical = ignore
let critical =
  Access.func uncontrolled_critical
  |> Access.once
  |> Access.duringHours 9 17
  |> Access.revokable

/// Try to evaluate
Access.eval () critical
/// Revoke when neccessary
Access.revoke critical

With full C# support!

using FPrimitive;

public class PositiveInt
{
    private PrositiveInt(int value) { Value = int; }

	public int value { get; }

	public static ValidationResult<PositiveInt> Create(int value)
	{
		return Spec.Of<int>()
			   .GreaterThan(0, "Positive integer should be greater than zero")
			   .CreateModel(value, validated => new PositiveInt(validated));
	}
}

Related Skills

View on GitHub
GitHub Stars33
CategoryDevelopment
Updated10d ago
Forks2

Languages

F#

Security Score

95/100

Audited on Mar 28, 2026

No findings