Module: NxtSchema
- Defined in:
- lib/nxt_schema.rb,
lib/nxt_schema/dsl.rb,
lib/nxt_schema/node.rb,
lib/nxt_schema/types.rb,
lib/nxt_schema/errors.rb,
lib/nxt_schema/version.rb,
lib/nxt_schema/callable.rb,
lib/nxt_schema/registry.rb,
lib/nxt_schema/node/base.rb,
lib/nxt_schema/node/leaf.rb,
lib/nxt_schema/undefined.rb,
lib/nxt_schema/node/error.rb,
lib/nxt_schema/node/schema.rb,
lib/nxt_schema/errors/error.rb,
lib/nxt_schema/error_messages.rb,
lib/nxt_schema/node/collection.rb,
lib/nxt_schema/node/constructor.rb,
lib/nxt_schema/validators/query.rb,
lib/nxt_schema/callable_or_value.rb,
lib/nxt_schema/node/has_subnodes.rb,
lib/nxt_schema/node/type_resolver.rb,
lib/nxt_schema/validators/pattern.rb,
lib/nxt_schema/node/template_store.rb,
lib/nxt_schema/validators/equality.rb,
lib/nxt_schema/validators/excluded.rb,
lib/nxt_schema/validators/excludes.rb,
lib/nxt_schema/validators/included.rb,
lib/nxt_schema/validators/includes.rb,
lib/nxt_schema/validators/registry.rb,
lib/nxt_schema/node/maybe_evaluator.rb,
lib/nxt_schema/validators/attribute.rb,
lib/nxt_schema/validators/less_than.rb,
lib/nxt_schema/validators/validator.rb,
lib/nxt_schema/validators/greater_than.rb,
lib/nxt_schema/node/validate_with_proxy.rb,
lib/nxt_schema/validators/optional_node.rb,
lib/nxt_schema/errors/invalid_options_error.rb,
lib/nxt_schema/node/default_value_evaluator.rb,
lib/nxt_schema/validators/less_than_or_equal.rb,
lib/nxt_schema/errors/schema_not_applied_error.rb,
lib/nxt_schema/validators/greater_than_or_equal.rb
Defined Under Namespace
Modules: Errors, Node, Types, Validators
Classes: Callable, CallableOrValue, ErrorMessages, Registry, Undefined
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.collection(name = :roots, **options, &block) ⇒ Object
6
7
8
|
# File 'lib/nxt_schema/dsl.rb', line 6
def collection(name = :roots, **options, &block)
Node::Collection.new(name: name, parent_node: nil, **options, &block)
end
|
.node ⇒ Object
32
33
34
|
# File 'lib/nxt_schema/dsl.rb', line 32
def schema(name = :root, **options, &block)
Node::Schema.new(name: name, parent_node: nil, **options, &block)
end
|
.nodes ⇒ Object
34
35
36
|
# File 'lib/nxt_schema/dsl.rb', line 34
def collection(name = :roots, **options, &block)
Node::Collection.new(name: name, parent_node: nil, **options, &block)
end
|
.params(name = :root, **options, &block) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/nxt_schema/dsl.rb', line 10
def params(name = :root, **options, &block)
Node::Schema.new(
name: name,
parent_node: nil,
**options.merge(
type_system: NxtSchema::Types::Params,
).reverse_merge(transform_keys: :to_sym),
&block
)
end
|
.register_error_messages(*paths) ⇒ Object
60
61
62
|
# File 'lib/nxt_schema.rb', line 60
def register_error_messages(*paths)
ErrorMessages.load(paths)
end
|
.register_type(key, type) ⇒ Object
56
57
58
|
# File 'lib/nxt_schema.rb', line 56
def register_type(key, type)
NxtSchema::Types.const_set(key.to_s, type)
end
|
.register_validator(validator, *keys) ⇒ Object
50
51
52
53
54
|
# File 'lib/nxt_schema.rb', line 50
def register_validator(validator, *keys)
keys.each do |key|
NxtSchema::Validators::Registry::VALIDATORS.register(key, validator)
end
end
|
.root ⇒ Object
33
34
35
|
# File 'lib/nxt_schema/dsl.rb', line 33
def schema(name = :root, **options, &block)
Node::Schema.new(name: name, parent_node: nil, **options, &block)
end
|
.roots ⇒ Object
35
36
37
|
# File 'lib/nxt_schema/dsl.rb', line 35
def collection(name = :roots, **options, &block)
Node::Collection.new(name: name, parent_node: nil, **options, &block)
end
|
.schema(name = :root, **options, &block) ⇒ Object
2
3
4
|
# File 'lib/nxt_schema/dsl.rb', line 2
def schema(name = :root, **options, &block)
Node::Schema.new(name: name, parent_node: nil, **options, &block)
end
|
Instance Method Details
#json(name = :root, **options, &block) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/nxt_schema/dsl.rb', line 21
def json(name = :root, **options, &block)
Node::Schema.new(
name: name,
parent_node: nil,
**options.merge(
type_system: NxtSchema::Types::JSON,
).reverse_merge(transform_keys: :to_sym),
&block
)
end
|