Skip to content

Releases: esbanarango/ember-model-validator

v.3.13.0

06 Jan 22:12
Compare
Choose a tag to compare

What's Changed

  • Fix for model.validate() causes error. (#185 reported by @ollar)
  • Bump ember-composable-helpers from 3.2.0 to 5.0.0 by @dependabot in #187
  • Bump ember-source-channel-url from 2.0.1 to 3.0.0 by @dependabot in #190

Full Changelog: v3.12.0...v.3.13.0

v3.12.0

29 Dec 22:02
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v3.11.0...v3.12.0

Release v3.11.0

03 Sep 02:45
Compare
Choose a tag to compare

💥 Breaking Change

Decorator instead of mixin

Before

import Model from "ember-data/model";
import attr from "ember-data/attr";
import Validator from "ember-model-validator/mixins/object-validator";

export default Model.extend(Validator, {
  fullName: attr("string"),
  fruit: attr("string"),
  color: attr("string"),

  validations: {
    fullName: {
      presence: true
    },
    fruit: {
      presence: true
    }
  }
});

After

import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import Validator from 'ember-model-validator/decorators/model-validator';

@Validator
class MyModel extends Model {
  @attr("string") fullName;
  @attr("string") fruit;
  @attr("string") color;

  validations = {
    fullName: {
      presence: true
    },
    fruit: {
      presence: true
    }
  }
}

export default MyModel;

Adding exclusion validator and support for custom message.

19 May 02:00
Compare
Choose a tag to compare
  validations: {
    name: {
      presence: true,
      inclusion: { in: ['Jose Rene', 'Aristi Gol', 'Armani'], message: 'Solo verde a morir' }
    },
    secondName: {
      exclusion: { in: ['Gionvany Hernandez', 'Wilder Medina'], message: 'Que iNrresponsabilidad' }
    },
    bussinessEmail: {
      presence: { message: 'sup dude, where\'s da email' },
      email: { message: 'Be professional ma men' }
    },
    mainstreamCode: {
      format: { with: /^[a-zA-Z]+$/, message: 'nu nu, that\'s not the format' }
    }
    alibabaNumber: {
      numericality: { message: 'is not abracadabra' }
    }
  }

Addition of Format validator + default messages.

18 May 02:50
Compare
Choose a tag to compare

format: {with: /^[a-zA-Z]+$/}

New DSL to define validations + Numericality

15 May 13:08
Compare
Choose a tag to compare

Before:

validations: {
  presence: ['name','email'],
  email: ['email'],
  relations: {
    hasMany:['otherFakes']
  }
}

Now:

  validations: {
    name: {
      presence: true
    },
    email: {
      presence: true,
      email: true
    },
    lotteryNumber: {
      numericality: true
    },
    otherFakes:{
      relations: ['hasMany']
    }
  }

Basic validations / First release!

14 May 04:22
Compare
Choose a tag to compare