# 06 Validations

This example shows you how to use validations in a signal.

These files can be found in the /Examples/\[example] and /Blackboards/Examples folders.

![Example 06 Validations editor](/files/JBYiLlRA8cIrkxua4lZf)

## ValidationsBlackboard.cs

```csharp
﻿using CrashKonijn.BlackboardPro.Blackboards.Examples.Attributes;
using CrashKonijn.RabbitBlackboard.Contracts;

namespace CrashKonijn.BlackboardPro.Blackboards.Examples
{
    public partial class ValidationsBlackboard : BlackboardBehaviour
    {
        // This value can never be less than 0
        // Note: that this is not the same attribute as the one Unity provides.
        [Min(0)]
        private int _bullets;

        // This is a custom validation that will capitalize the string
        // It can be viewed in ./Attributes/CapitalizeAttribute.cs
        [Capitalize]
        private string _name;

        // Validations can be stacked!
        // This value can never be less than 0 or greater than 150
        [Min(0)]
        [Max(150)]
        private int _health;

        // This is a computed signal that is normalized health between 0 and 1.
        // Even if health becomes higher than 100, this value will never be higher than 1.
        [Normalize(100f, true)]
        private static float _normalizedHealth(Signals.Health health) => health.Value;

        // This is a computed signal that is a curve between 0 and 1.
        [EaseInOutCurve(0f, 1f, 1f, 0f, 2f)]
        [MinMax(0f, 1f)]
        private static float _shouldHeal(Signals.NormalizedHealth health) => health.Value;
    }
}

```

## ValidationsHealthBehaviour.cs

```csharp
﻿using CrashKonijn.BlackboardPro.Blackboards.Examples;
using CrashKonijn.RabbitBlackboard.Contracts;
using UnityEngine;

namespace CrashKonijn.BlackboardPro.Examples._06_validations
{
    [RequireComponent(typeof(ValidationsBlackboard))]
    public class ValidationsHealthBehaviour : MonoBehaviour
    {
        /* Simple hack to show a button in the editor */
        [Header("Removes 10 health.")]
        [Button(nameof(DoDamage))]
        public string doDamageButton;

        /* Simple hack to show a button in the editor */
        [Header("Adds 10 health")]
        [Button(nameof(Heal))]
        public string healButton;

        /* Simple hack to show a button in the editor */
        [Header("Add 5 bullets.")]
        [Button(nameof(AddBullets))]
        public string addBulletsButton;

        /* Simple hack to show a button in the editor */
        [Header("Removed 5 bullets")]
        [Button(nameof(RemoveBullets))]
        public string removeBulletsButton;

        private ValidationsBlackboard blackboard;

        public ValidationsBlackboard Blackboard
        {
            get
            {
                if (this.blackboard == null)
                {
                    this.blackboard = this.GetComponent<ValidationsBlackboard>();
                }

                return this.blackboard;
            }
        }

        public void DoDamage()
        {
            this.Blackboard.Health -= 10;
        }

        public void Heal()
        {
            this.Blackboard.Health += 10;
        }

        public void AddBullets()
        {
            this.Blackboard.Bullets += 5;
        }

        public void RemoveBullets()
        {
            this.Blackboard.Bullets -= 5;
        }
    }
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blackboard.crashkonijn.com/examples/06_validations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
