Closed kuba-orlik closed 9 years ago
Do you think about this case?
isProperValue
in developer discretionYeah, I think that the code for the "only red-shaded colors" field-type could look like:
var reddish_color = new Sealious.ChipTypes.FieldType({
name: "reddish_color",
inherit_from: "color",
isProperValue: function(context, new_value){
//...check the value for redness
}
});
Any value provided for such field type would be first checked by color
field-type's .isProperValue
method, and just then by reddish_color
's .isProperValue
. Only value that is deemed proper by both of these methods is considered proper for fields of type reddish_color
What do you think?
In my opinion isProperValue
method should be execute once by new FieldType
inherit from color
. Unfortunately that isn't possible because developer must be know structure about default color
.
Your idea is good solution. I can do it. Where should be prototype function for inheritance?
All the changes for inheritance were written during works on #206, so I'm closing this issue, as #206 branch is going to be merged soon, anyway.
Perhaps a field-type should have the ability to work sort of as a subset of another field-type, e.g. one should be able to create a field-type that accepts only colors that are shades of red - in this case the field-type's
isProperValue
method would first ask thecolor
field type if the providednew_value
is a proper color value. Any thoughts?