Validator for readonly literal values
| 2240 | |
| 2241 | |
| 2242 | class LiteralValidator(BaseValidator): |
| 2243 | """ |
| 2244 | Validator for readonly literal values |
| 2245 | """ |
| 2246 | |
| 2247 | def __init__(self, plotly_name, parent_name, val, **kwargs): |
| 2248 | super(LiteralValidator, self).__init__( |
| 2249 | plotly_name=plotly_name, parent_name=parent_name, **kwargs |
| 2250 | ) |
| 2251 | self.val = val |
| 2252 | |
| 2253 | def validate_coerce(self, v): |
| 2254 | if v != self.val: |
| 2255 | raise ValueError( |
| 2256 | """\ |
| 2257 | The '{plotly_name}' property of {parent_name} is read-only""".format( |
| 2258 | plotly_name=self.plotly_name, parent_name=self.parent_name |
| 2259 | ) |
| 2260 | ) |
| 2261 | else: |
| 2262 | return v |
| 2263 | |
| 2264 | |
| 2265 | class DashValidator(EnumeratedValidator): |
no outgoing calls