How to use the clay.FieldValidationError function in clay

To help you get started, we’ve selected a few clay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yipit / clay.js / test / unit / fields.js View on Github external
'*"auto"* assigns the current *date/time*': function(kinds) {
            assert.doesNotThrow(function(){
                assert.equal(
                    kinds.auto(null, null, null),
                    (new Date()).toString()
                );
            }, models.FieldValidationError);
        },
        '*"auto"* should ignore a valid date string': function(kinds) {
github Yipit / clay.js / test / unit / issues.js View on Github external
'it complains when declared one to many relationships have bad names': function(){
        var our_hope_away = function(){
            var Wicked = models.declare("Wicked", function(it, kind){
                it.has.one('some rel', function(){});
            });
        }

        should.throws(our_hope_away, models.FieldValidationError);

        try {
            our_hope_away();
        } catch (e) {
            e.message.should.equal('The declaration of the model "Wicked" specifies a relationship with a bad name: "some rel". In those cases use just numbers, letters and underscore');
        }
    },
    'it complains when declared many to one relationships have bad names': function(){
github Yipit / clay.js / test / unit / fields.js View on Github external
'string accepts anything': function(kinds) {
            assert.doesNotThrow(function(){
                assert.equal(
                    kinds.string(null, null, 1234567),
                    "1234567"
                );
            }, models.FieldValidationError);
        },
        '*"auto"* assigns the current *date/time*': function(kinds) {
github Yipit / clay.js / test / unit / issues.js View on Github external
'it complains when declared fields have bad names': function(){
        var our_hope_away = function(){
            var Wicked = models.declare("Wicked", function(it, kind){
                it.has.field('some field', kind.string);
            });
        }

        should.throws(our_hope_away, models.FieldValidationError);

        try {
            our_hope_away();
        } catch (e) {
            e.message.should.equal('The declaration of the model "Wicked" specifies a field with a bad name: "some field". In those cases use just numbers, letters and underscore');
        }
    },
    'it complains when declared indexes have bad names': function(){