Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation for State Machine Configuration Structure #91

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d30af74
WB-784: feat(state-config): add StateConfigValidator class
deligoez Dec 12, 2024
e002e7b
WB-784: feat(state-config-validator): add array/string normalization …
deligoez Dec 12, 2024
08d1dad
WB-784: feat(state-config-validator): add machine config validation m…
deligoez Dec 12, 2024
9c5fbf3
WB-784: feat(validator): add root-level configuration validation
deligoez Dec 12, 2024
ca46f32
WB-784: refactor(stateconfigvalidator): use named arguments for clarity
deligoez Dec 12, 2024
53b6d8d
WB-784: feat(config-validation): add state configuration validation
deligoez Dec 12, 2024
789e27e
WB-784: feat(state-validator): add state type validation
deligoez Dec 12, 2024
d1ef57b
WB-784: feat(state-validator): add validation for final state constra…
deligoez Dec 12, 2024
b494aa5
WB-784: feat(state-config-validator): add validation for state entry/…
deligoez Dec 12, 2024
fa68341
WB-784: feat(state-validation): add transitions configuration validation
deligoez Dec 12, 2024
b4cc932
WB-784: feat(state-validator): add validation for single transition c…
deligoez Dec 12, 2024
f808b50
WB-784: feat(validator): add transition config validation
deligoez Dec 12, 2024
b740b52
WB-784: feat(validator): add transition behaviors validation
deligoez Dec 12, 2024
1cf3ea8
WB-784: feat(validator): add validation for guarded transitions
deligoez Dec 12, 2024
2ba249c
WB-784: feat(machine): add state config validation during initialization
deligoez Dec 12, 2024
e1840d1
WB-784: test(state-config-validator): add test for root key validation
deligoez Dec 12, 2024
861b92f
WB-784: test(stateconfigvalidator): add test for valid root level config
deligoez Dec 12, 2024
3bc2ceb
WB-784: test(stateconfigvalidator): add test for valid root level config
deligoez Dec 12, 2024
048f92a
WB-784: test(state-config-validator): add test for invalid transition…
deligoez Dec 12, 2024
a1d48ca
WB-784: test(stateconfigvalidator): add test for validating 'on' prop…
deligoez Dec 12, 2024
599b019
WB-784: test(stateconfigvalidator): add test for invalid transition t…
deligoez Dec 12, 2024
67dd54f
WB-784: test(stateconfigvalidator): add test for allowed keys validation
deligoez Dec 12, 2024
f5a09bd
WB-784: test(stateconfigvalidator): add test for invalid state type v…
deligoez Dec 12, 2024
1c9e1d5
WB-784: test(state-config-validator): add test for final state transi…
deligoez Dec 12, 2024
9e57651
WB-784: test(stateconfigvalidator): add test for final states without…
deligoez Dec 12, 2024
0028e4c
WB-784: test(stateconfigvalidator): add test for comprehensive state …
deligoez Dec 12, 2024
276b314
WB-784: test(stateconfigvalidator): add test for normalizing string b…
deligoez Dec 12, 2024
34bfd47
WB-784: test(stateconfigvalidator): add test for empty guarded transi…
deligoez Dec 12, 2024
99fd4db
WB-784: test(stateconfigvalidator): add test for default condition or…
deligoez Dec 12, 2024
4e2ffaa
WB-784: test(stateconfigvalidator): add test for required target in g…
deligoez Dec 12, 2024
5a87027
WB-784: test(state-config-validator): add test for valid guarded tran…
deligoez Dec 12, 2024
33c46f7
WB-784: fix(stateconfigvalidator): clarify error message for invalid …
deligoez Dec 12, 2024
390e8e3
WB-784: refactor(stateconfigvalidator): differentiate error labels fo…
deligoez Dec 12, 2024
db79265
WB-784: fix(state-validator): improve condition validation error message
deligoez Dec 12, 2024
46a735e
WB-784: test(state-config-validator): add test for validating conditi…
deligoez Dec 12, 2024
af085ba
WB-784: test(stateconfigvalidator): add test for invalid actions conf…
deligoez Dec 12, 2024
735b6c6
WB-784: test(stateconfigvalidator): add test for invalid calculators …
deligoez Dec 12, 2024
db5f470
WB-784: test(stateconfigvalidator): add test for validating entry/exi…
deligoez Dec 12, 2024
7e560c7
WB-784: test(stateconfigvalidator): add test for invalid guards confi…
deligoez Dec 12, 2024
abe9843
WB-784: feat(validator): add 'id' and 'result' to allowed state keys
deligoez Dec 12, 2024
8a3a310
WB-784: test(state): remove tests for invalid final state definitions
deligoez Dec 12, 2024
0d8c68f
WB-784: fix(tests): simplify StateDefinitionTypeTest result callback
deligoez Dec 12, 2024
1bb8957
WB-784: fix(state-config-validator): consolidate default condition va…
deligoez Dec 13, 2024
e62d300
WB-784: fix(machine-definition): remove unused parameter in validation
deligoez Dec 13, 2024
124ef5e
WB-784: fix(machine-definition): reorder condition check to prevent e…
deligoez Dec 13, 2024
9b5281e
WB-784: feat(definition): support InvokableBehavior in return type
deligoez Dec 13, 2024
cb45d57
WB-784: fix(machine-definition): correct parameter passed to getScena…
deligoez Dec 13, 2024
7f0613f
WB-784: fix(machine-definition): correct null safe operator usage
deligoez Dec 13, 2024
3ada833
WB-784: fix(definition): use static method call for context validation
deligoez Dec 13, 2024
9b2181a
WB-784: fix(transition): call validateRequiredContext statically in G…
deligoez Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WB-784: feat(state-validator): add state type validation
Introduce `validateStateType` method to enforce allowed state types. Throws `InvalidArgumentException` for invalid states, improving validation robustness.
deligoez committed Dec 12, 2024
commit 789e27e38b1f1357c772d7892b8c2b45be1c733b
15 changes: 15 additions & 0 deletions src/StateConfigValidator.php
Original file line number Diff line number Diff line change
@@ -160,4 +160,19 @@ private static function validateStateConfig(?array $stateConfig, string $path):
self::validateTransitionsConfig(transitionsConfig: $stateConfig['on'], path: $path);
}
}

/**
* Validates state type configuration.
*
* @throws InvalidArgumentException
*/
private static function validateStateType(array $stateConfig, string $path): void
{
if (!in_array($stateConfig['type'], haystack: self::VALID_STATE_TYPES, strict: true)) {
throw new InvalidArgumentException(
message: "State '{$path}' has invalid type: {$stateConfig['type']}. ".
'Allowed types are: '.implode(separator: ', ', array: self::VALID_STATE_TYPES)
);
}
}
}