Class: LcpRuby::Metadata::ConfigurationValidator
- Inherits:
-
Object
- Object
- LcpRuby::Metadata::ConfigurationValidator
- Defined in:
- lib/lcp_ruby/metadata/configuration_validator.rb
Overview
Comprehensive configuration validator that checks both structural integrity and business logic consistency across all YAML metadata.
Unlike the per-definition validate! methods (which check individual file syntax), this validator cross-references models, presenters, and permissions to catch issues like broken associations, invalid field references, duplicate slugs, etc.
Defined Under Namespace
Classes: ConditionValidationContext, ValidationResult
Constant Summary collapse
- LCP_MANAGED_HINT =
Hint appended to bind_to_apply error messages for the rejected ‘[associations]` and `[schema]` values. The validator no longer accepts these as feature-group flags; instead users opt in per-item with `lcp_managed: true` on individual fields/associations rows. See docs/design/bind_to_managed_fields_and_associations.md.
"For per-item control, set `lcp_managed: true` on individual " \ "`%{kind}:` rows in YAML. See " \ "docs/design/bind_to_managed_fields_and_associations.md."
- VALID_CRUD_ACTIONS =
%w[index show create update destroy restore permanently_destroy].freeze
- VALID_CONDITION_OPERATORS =
%w[eq not_eq neq in not_in gt gte lt lte present blank matches not_matches starts_with ends_with contains not_contains any_of empty not_empty].freeze
- BUILT_IN_ACTION_NAMES =
%w[show edit destroy create update restore permanently_destroy].freeze
- VALID_SORT_DIRECTIONS =
%w[asc desc].freeze
- NUMERIC_OPERATORS =
%w[gt gte lt lte].freeze
- REGEX_OPERATORS =
%w[matches not_matches].freeze
- STRING_OPERATORS =
%w[starts_with ends_with contains].freeze
- NUMERIC_TYPES =
%w[integer float decimal date datetime].freeze
- TEXT_TYPES =
%w[string text].freeze
- VALID_DIALOG_SIZES =
%w[small medium large fullscreen].freeze
Instance Attribute Summary collapse
-
#loader ⇒ Object
readonly
Returns the value of attribute loader.
Class Method Summary collapse
-
.valid_accent_tokens ⇒ Object
Single source of truth — the runtime helper’s whitelist.
-
.validate_auth!(raw:, providers:) ⇒ Object
Class-method entry point for auth.yml validation, called by ProviderRegistry at boot.
Instance Method Summary collapse
-
#initialize(loader) ⇒ ConfigurationValidator
constructor
A new instance of ConfigurationValidator.
- #validate ⇒ Object
Constructor Details
#initialize(loader) ⇒ ConfigurationValidator
Returns a new instance of ConfigurationValidator.
59 60 61 62 63 |
# File 'lib/lcp_ruby/metadata/configuration_validator.rb', line 59 def initialize(loader) @loader = loader @errors = [] @warnings = [] end |
Instance Attribute Details
#loader ⇒ Object (readonly)
Returns the value of attribute loader.
57 58 59 |
# File 'lib/lcp_ruby/metadata/configuration_validator.rb', line 57 def loader @loader end |
Class Method Details
.valid_accent_tokens ⇒ Object
Single source of truth — the runtime helper’s whitelist. Lazy because ‘app/helpers` autoload is not wired up while gem code loads at boot.
1531 1532 1533 |
# File 'lib/lcp_ruby/metadata/configuration_validator.rb', line 1531 def self.valid_accent_tokens LcpRuby::Display::CardHelper::ACCENT_TOKENS.keys end |
.validate_auth!(raw:, providers:) ⇒ Object
Class-method entry point for auth.yml validation, called by ProviderRegistry at boot. Runs JSON-Schema validation on the raw YAML hash plus 12 cross-cutting checks that cannot be expressed in the schema (e.g. role_source: host requires a configured role_resolver).
Raises LcpRuby::Authentication::ConfigurationError on the first blocking violation; warnings (e.g. external_id: email) are emitted via Rails.logger.warn so they show up in dev/test without aborting boot.
Arguments:
raw — full parsed YAML document (root hash with top-level "auth" key)
providers — Array<LcpRuby::Authentication::Provider> already constructed
77 78 79 |
# File 'lib/lcp_ruby/metadata/configuration_validator.rb', line 77 def self.validate_auth!(raw:, providers:) AuthValidator.new(raw: raw, providers: providers).validate! end |
Instance Method Details
#validate ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/lcp_ruby/metadata/configuration_validator.rb', line 81 def validate @errors = [] @warnings = [] # Ensure renderer registry is populated so per-entry checks # (validate_entry_renderer) don't re-init in inner loops, and so # the validator works in non-booted contexts (isolated specs). # register_built_ins! is idempotent. LcpRuby::Display::RendererRegistry.register_built_ins! # Phase 1: Structural validation via JSON Schema validate_schemas # Phase 2: Cross-reference validation (semantic) validate_models validate_associations validate_association_primary_keys! validate_presenters validate_tenant_cascade validate_pages validate_uniqueness validate_view_groups validate_custom_fields validate_role_model validate_group_models validate_workflows validate_job_definitions validate_sti_models validate_presenter_reachability validate_record_aliases_and_slug_fields validate_auth_yml validate_serialization_integrity ValidationResult.new(errors: @errors.dup, warnings: @warnings.dup) end |