15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/meta/id.rb', line 15
def errors
if (my[:max].to_i > 0) && (val.size > my[:max])
[_('too long: %{max} characters maximum') % {:max => my[:max]}]
elsif (my[:min].to_i == 1) && val.empty?
[_('mandatory')]
elsif (my[:min].to_i > 0) && (val.size < my[:min])
[_('too short: %{min} characters minimum') % {:min => my[:min]}]
elsif val !~ /\A#{Runo::REX::ID_SHORT}\z/
[_('malformatted id')]
elsif (
my[:parent] &&
my[:parent][:id] !~ /00000000_#{val}$/ &&
my[:parent][:parent].is_a?(Runo::Set::Dynamic) &&
my[:parent][:parent].item(val)
)
[_('duplicate id: %{id}') % {:id => val}]
else
[]
end
end
|