Example
package User;
use Ernst;
has 'username' => (
is => 'ro',
isa => 'Str',
traits => ['MetaDescription'],
description => {
type => 'String',
traits => [qw/CSS TT::Snippet Validation Collection/],
max_length => 64,
expected_length => 40,
unique_attribute => 1,
css_id => '#openid',
snippet_class => 'MyApp::Snippet::OpenID'
validate => [
{ regexp => qr{^http://},
error => 'Your OpenID must start with http://', }
],
},
);
- The idea is "give other things enough data to make the right decision"
- Database
- username is the primary key
- field type is VARCHAR(64)
- Web form
- use MyApp::Snippet::OpenID to render the field
- apply the #openid CSS id
- validate with rules (regexp, max_length, etc.)
- make the field about 40 characters long (average length)
- REST API
- create
- update
- retrieve
- client can use the same class!