Class: AgentSkills::Validator
- Inherits:
-
Object
- Object
- AgentSkills::Validator
- Defined in:
- lib/agent_skills/validator.rb
Constant Summary collapse
- NAME_REGEX =
/\A[a-z0-9]+(-[a-z0-9]+)*\z/- MAX_NAME_LENGTH =
64- MAX_DESCRIPTION_LENGTH =
1024- MAX_COMPATIBILITY_LENGTH =
500
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#skill ⇒ Object
readonly
Returns the value of attribute skill.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(skill) ⇒ Validator
constructor
A new instance of Validator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(skill) ⇒ Validator
Returns a new instance of Validator.
12 13 14 15 |
# File 'lib/agent_skills/validator.rb', line 12 def initialize(skill) @skill = skill @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
10 11 12 |
# File 'lib/agent_skills/validator.rb', line 10 def errors @errors end |
#skill ⇒ Object (readonly)
Returns the value of attribute skill.
10 11 12 |
# File 'lib/agent_skills/validator.rb', line 10 def skill @skill end |
Class Method Details
.validate!(skill) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/agent_skills/validator.rb', line 26 def self.validate!(skill) validator = new(skill) return skill if validator.valid? raise ValidationError, validator.errors.join(", ") end |
Instance Method Details
#valid? ⇒ Boolean
17 18 19 20 21 22 23 24 |
# File 'lib/agent_skills/validator.rb', line 17 def valid? @errors = [] validate_name validate_description validate_compatibility validate_directory_match @errors.empty? end |