Class AchievementDefinitionValidator
Answers whether an AchievementDefinitionCreator.Input can be written, and says why not when it cannot. Reached through Validate(Input) and ValidateIdentity(string, string) — this type is where the rules live, those are the API every window and test calls.
Inherited Members
Namespace: Serenity.Achievements.Infrastructure.Editor.Builder
Assembly: Serenity.UnityAchievements.Infrastructure.Editor.dll
Syntax
public static class AchievementDefinitionValidator
Remarks
Split out of the creator for the same reason AchievementSettingsValidator is: deciding whether a request is authorable and actually authoring it are two jobs with different reasons to change.
Almost nothing is decided here. What makes an achievement work is AchievementAuthoringRules — the engine-free rules the inspector, the project validator and the headless run all answer with — and this type asks them. It owns only the two questions those rules cannot ask, because they are about the PROJECT rather than about the achievement: which other asset already carries this Id, and whether the target path is free.
Methods
Validate(Input, UnityAchievementDefinition)
Every rule, in the order an author reads them: who this achievement is, what the player sees, what unlocks it, and where it lands.
Declaration
public static SerenityCreationValidationResult Validate(AchievementDefinitionCreator.Input input, UnityAchievementDefinition assetBeingEdited)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementDefinitionCreator.Input | input | What would be authored. |
| UnityAchievementDefinition | assetBeingEdited | The achievement being updated in place, excluded from the Id collision rules so an edit that keeps its own Id is not reported as a duplicate of itself, and exempt from the occupied-path rule because an update writes no new file. Null when validating a creation. |
Returns
| Type | Description |
|---|---|
| SerenityCreationValidationResult | The findings. |
Remarks
The shared rules' own duplicate-Id finding is dropped precisely so that answer is given once, by the pass below that can tell an in-folder collision (a file-name clash, fatal) from a distant one (ambiguous resolution, a warning).
Validate(Input, UnityAchievementDefinition, IReadOnlyCollection<AchievementPlatformKind>)
Every rule, judged against a set of storefronts the caller already holds.
Declaration
public static SerenityCreationValidationResult Validate(AchievementDefinitionCreator.Input input, UnityAchievementDefinition assetBeingEdited, IReadOnlyCollection<AchievementPlatformKind> enabledPlatforms)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementDefinitionCreator.Input | input | What would be authored. |
| UnityAchievementDefinition | assetBeingEdited | The achievement being updated in place, or null when validating a creation. |
| IReadOnlyCollection<AchievementPlatformKind> | enabledPlatforms | The storefronts the project ships on. Empty or null silences the platform rule, which is the honest answer for a project that mirrors unlocks nowhere. |
Returns
| Type | Description |
|---|---|
| SerenityCreationValidationResult | The findings. |
Remarks
The storefront list is a parameter rather than something this pass reads for itself, because reading it walks every settings asset in the project and the answer cannot change while a window is open. A Studio resolves it once per session through EnabledPlatformsInProject() and validates a whole list against it; the overload above is the convenience for a one-off call.
ValidateIdentity(string, string)
Id-only validation, usable from a "New Achievement" prompt before anything else is filled in.
Declaration
public static SerenityCreationValidationResult ValidateIdentity(string achievementId, string targetFolder)
Parameters
| Type | Name | Description |
|---|---|---|
| string | achievementId | The Id being typed. |
| string | targetFolder | The folder the achievement would land in. |
Returns
| Type | Description |
|---|---|
| SerenityCreationValidationResult | The findings: a blank or non-slug Id and an Id already taken in this folder are errors, an Id taken elsewhere in the project is a warning. |
Remarks
Deliberately does NOT read which storefronts the project ships on. This runs on every keystroke of a prompt; answering that question walks every settings asset in the project, and the only findings it could produce belong to the Platform section, which this pass discards.