Module: Opencdd::Validator
- Defined in:
- lib/opencdd/validator.rb,
lib/opencdd/validator/rule.rb,
lib/opencdd/validator/runner.rb,
lib/opencdd/validator/set_rule.rb,
lib/opencdd/validator/enum_rule.rb,
lib/opencdd/validator/irdi_rule.rb,
lib/opencdd/validator/type_rule.rb,
lib/opencdd/validator/format_rule.rb,
lib/opencdd/validator/pattern_rule.rb,
lib/opencdd/validator/synonym_rule.rb,
lib/opencdd/validator/condition_rule.rb,
lib/opencdd/validator/data_type_rule.rb,
lib/opencdd/validator/hierarchy_rule.rb,
lib/opencdd/validator/mandatory_rule.rb,
lib/opencdd/validator/reference_rule.rb,
lib/opencdd/validator/uniqueness_rule.rb,
lib/opencdd/validator/class_reference_rule.rb
Defined Under Namespace
Classes: ClassReferenceRule, ConditionRule, DataTypeRule, EnumRule, FormatRule, HierarchyRule, IrdiRule, MandatoryRule, PatternRule, ReferenceRule, Rule, Runner, SetRule, SynonymRule, TypeRule, UniquenessRule, ValidationError
Class Method Summary collapse
- .class_hierarchy_acyclic?(database) ⇒ Boolean
-
.irdi_well_formed?(value) ⇒ Boolean
── Reusable predicates (plan 10 public API).
- .mandatory_present?(value) ⇒ Boolean
- .pattern_valid?(value, pattern) ⇒ Boolean
-
.run(database, **opts) ⇒ Object
Composite runner — applies every rule to every entity's every property, plus the database-level invariants (class-hierarchy acyclicity).
Class Method Details
.class_hierarchy_acyclic?(database) ⇒ Boolean
64 65 66 |
# File 'lib/opencdd/validator.rb', line 64 def class_hierarchy_acyclic?(database) HierarchyRule.class_hierarchy_acyclic?(database) end |
.irdi_well_formed?(value) ⇒ Boolean
── Reusable predicates (plan 10 public API). Each wraps an existing rule class so the OpenCDD Editor's live validator (TS port) can share the same semantics as the Ruby gem. ──
46 47 48 49 50 51 |
# File 'lib/opencdd/validator.rb', line 46 def irdi_well_formed?(value) return false if value.nil? || value.to_s.strip.empty? !Opencdd::IRDI.parse(value.to_s).nil? rescue Opencdd::IRDI::ParseError false end |
.mandatory_present?(value) ⇒ Boolean
53 54 55 |
# File 'lib/opencdd/validator.rb', line 53 def mandatory_present?(value) !value.nil? && !value.to_s.strip.empty? end |
.pattern_valid?(value, pattern) ⇒ Boolean
57 58 59 60 61 62 |
# File 'lib/opencdd/validator.rb', line 57 def pattern_valid?(value, pattern) return false if pattern.nil? || pattern.to_s.empty? Regexp.new(pattern).match?(value.to_s) rescue RegexpError false end |
.run(database, **opts) ⇒ Object
Composite runner — applies every rule to every entity's every
property, plus the database-level invariants (class-hierarchy
acyclicity). Returns an Array of ValidationError records
that the UI / CI can render as a clickable list.
38 39 40 |
# File 'lib/opencdd/validator.rb', line 38 def run(database, **opts) Runner.run(database, **opts) end |